Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Hovering mouse over next available rock to mine?


    Chuppa
     Share

    Recommended Posts

    Hey folks,

    I've been making a rock mining script and it works okay, but one thing I'd like to implement is hovering over the next available rock to mine.

    Here's the relevant code:

    public static final Filter<GameObject> ORE_FILTER = GameObject -> GameObject != null
                //filters out the wrong stuff
        public static final Filter<GameObject> NEXT_ORE_FILTER = GameObject -> GameObject != null
                //filters out the wrong stuff and finds the next rock with distance to character > 1 (as to not select the rock that i am already mining)
                && GameObject.distance() > 1;
      
      	if(!getInventory().isFull()) {
                    GameObject ORE = getGameObjects().closest(ORE_FILTER);
                    int miningxp = getSkills().getExperience(Skill.MINING);
                    if (ORE != null) {
                        if(ORE.interact("Mine")) {
                            sleepUntil(() -> miningxp != getSkills().getExperience(Skill.MINING), 7000);
                        }
                    }

    ^^ is basically how it currently looks which works fine but doesn't hover

    if(!getInventory().isFull()) {
                    GameObject ORE = getGameObjects().closest(ORE_FILTER);
                    int miningxp = getSkills().getExperience(Skill.MINING);
                    if (ORE != null) {
    					GameObject NEXT_ORE = getGameObjects().closest(NEXT_ORE_FILTER);
    					getMouse().drag(NEXT_ORE);
                        if(ORE.interact("Mine")) {
                            sleepUntil(() -> miningxp != getSkills().getExperience(Skill.MINING), 7000);
                        }
                    }

    ^^ I've tried that solution which does hover the mouse over the next rock however when it clicks the next ore it seems to double click? Any ideas on how to solve this situation?

     

    Cheers

    Link to comment
    Share on other sites

    Does this forum not allow for editing my old posts? I just noticed that I've managed to fuck the indentation while copy-pasting, whoops. 

    Link to comment
    Share on other sites

    Alright I solved the problem, it seems drag is a bit buggy and for some reason does a click when it starts which is not noted in API. Fortunately move() seems to work, I'll add the working code below:

    	GameObject ORE = getGameObjects().closest(ORE_FILTER);
    	int miningxp = getSkills().getExperience(Skill.MINING);
    	if (ORE != null) {
    		if(ORE.interact("Mine")) {
    			sleepUntil(() -> getLocalPlayer().isAnimating(), 5000);
    			GameObject NEXT_ORE = getGameObjects().closest(NEXT_ORE_FILTER);
    			if(getMouse().move(NEXT_ORE)) {
    				sleepUntil(() -> miningxp != getSkills().getExperience(Skill.MINING), 7000);
    			}
    		}
    	}

     

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.