Jump to content

Never really coded in java, where to start


archiebaker

Recommended Posts

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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