Jump to content

Never really coded in java, where to start


Recommended Posts

Posted (edited)

I literally went over this about 5-10 minutes after writing this post! The guide was really informative! Its more the fact I don't understand how to open banks reliably (Without spam clicking) etc which is more where I'm trying to learn stuff from. 

 

I've been looking at the API and picked up a bit but some of it still confuses me because not that many of them have understandable examples D:

 

Also any idea why this isn't working? I guess i forgot to define its class (Or whatever its called) at  the top of the project?

attachicon.gifbank.png

 

The simplest way to open a bank without spam clicking is using the following method:

public void openBank() throws InterruptedException{
        
    getBank().open(); // Open the bank
    new ConditionalSleep(5000) { // Sleep until the bank is open, or for 5 seconds
        @Override
        public boolean condition() throws InterruptedException {
            return getBank().isOpen();
        }
    }.sleep();
}

The same logic can be applied to many different tasks in scripts. For example, if you wanted to chop down a tree, to prevent spam clicking you could do something like:

@Override
public int onLoop throws InterruptedException {

    if(!myPlayer().isAnimating()){

        chopDownTree(); // Chop down a tree if we're not animating
    }
    return random(200, 300);
}

private void chopDownTree(){

    RS2Object tree = S.getObjects().closest("Tree");
    if(tree != null){
            
        tree.interact("Chop down"); // Chop down the tree
        new ConditionalSleep(5000) { // Sleep until the player is animating, or for 5 seconds
            @Override
            public boolean condition() throws InterruptedException {
                return S.myPlayer().isAnimating();
            }
        }.sleep();
    }
}
Edited by Explv
Posted

Thankyou both guys! One last thing... How do i make my bot walk? I understand (I think) how to set locations just not entirely sure how to make it move, i'll decompile some jars and look into that but I thought I might as well ask here too

 

:???:

getWalking().walk(position);

or

getWalking().webWalk(position);

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...