Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with world hopping in script

Featured Replies

So I have made a very beginner script but it did the job until I wanted to add world hopping.

Each time my code is executing, the script doesn't wait for the world hopping to take place, it just opens the world hopping menu and goes to trade once again.

I tried adding sleeps too after "worldHop1" but it only made the world hopping take this amount of time and still didn't even hop afterwards, just trades again.

I would really appreciate it if someone can help me regarding this!

Here is the part of my script that I am talking about:

@Override
public int onLoop() throws InterruptedException {



    isReadyToTrade();
    trade();
    sleep(3000);
    Buy();
    sleep(3000);
    ExitStore();
    sleep(5000);
    checkInventory();
    sleep(3000);
    worldHop1();



    return 0;

    
}



public void worldHop1(){
    getWorlds().hop(308);

    }

Edited by mrdukesilver

@mrdukesilver

Without having knowledge of the code inside of the other methods, this will be rather hard to debug.

Try executing only the worldHop1 method without executing any other code to see if it functions as expected.

I also recommend to look into the ConditionalSleep classes.

Standard ConditionalSleep class

 new ConditionalSleep(maxSleepTime, checkInterval) {
     @Override
     public boolean condition() throws InterruptedException {
         return condition;
     }
 }.sleep();

Non-Standard ConditionalSleep class - I personally recommend using this one, as it is more straightforward.

ConditionalSleep2.sleep(maxSleepTime, () -> condition)

 

Edited by BravoTaco

  • 2 weeks later...
  • Author
On 2/5/2022 at 1:47 AM, BravoTaco said:

@mrdukesilver

Without having knowledge of the code inside of the other methods, this will be rather hard to debug.

Try executing only the worldHop1 method without executing any other code to see if it functions as expected.

I also recommend to look into the ConditionalSleep classes.

Standard ConditionalSleep class

 new ConditionalSleep(maxSleepTime, checkInterval) {
     @Override
     public boolean condition() throws InterruptedException {
         return condition;
     }
 }.sleep();

Non-Standard ConditionalSleep class - I personally recommend using this one, as it is more straightforward.

ConditionalSleep2.sleep(maxSleepTime, () -> condition)

 

Hey! , tysm for responding, can u tell me how can I use this in my code, could you kindly provide me an example pls?

On 2/17/2022 at 2:04 PM, mrdukesilver said:

Hey! , tysm for responding, can u tell me how can I use this in my code, could you kindly provide me an example pls?

Sure! No problem!

// Basic code to chop a regular tree, with a conditional sleep, when the player is not animating.
if (!myPlayer().isAnimating()) {
    RS2Object tree = getObjects().closest("Tree");
    if (tree != null && tree.interact("Chop down")) {
        // The conditional sleep returns true or false.
        // True being returned if the condition is met. IE. The player is animating.
        // False being returned if the condition is not met, and the max sleep time is met.
        // The sleep time is in milliseconds so 15000 == 15 seconds.
        if (ConditionalSleep2.sleep(15000, () -> myPlayer().isAnimating())) {
            log("Player is chopping the tree.");
        }
    }
}

Edited by BravoTaco

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.