Jump to content

Problems with hopping worlds


Laurow

Recommended Posts

Hello, I'm recently experiencing issues with hopping worlds, although 2 days ago it worked flawlessly in testing. It seems to not scroll to the world tab menu and also not click on the next world as stated. I tried opening the world selector before starting my script but nothing seemd to do the job. Is my script suddenly broken or is it something with OSBot what's causing this?

 

(I'm kinda new into scripting, also without any programming experience, so I'm here just testing the waters so please don't offend me in the way I code things lmao, I'm already happy if it does the job :) )

        // Hop to the next world
        log ("Time to hop!");
        sleep(random(1500,2500));

        getWidgets().closeOpenInterface();
        
        sleep(random(300,500));

        getLogoutTab().open();

        while (getLogoutTab().isOpen()) {

            if (worlds.getCurrentWorld() == 302) {
                worlds.hop(303);
            }
            if (worlds.getCurrentWorld() == 303) {
                worlds.hop(304);
            }
            if (worlds.getCurrentWorld() == 304) {
                worlds.hop(305);
            }

etc etc

 

Link to comment
Share on other sites

There's a bunch of things here.

1) Never user a while loop in a script. There's always an alternative.

2) You don't need to explicitly close most interfaces or open a tab for world hopping.

3) You should use if else statements wherever possible.

Realistically, your script should look something like:
 

        log("Time to hop!");
        if(getWorlds().getCurrentWorld() == 302){
            if(worlds.hop(303)){
                Sleep.sleepUntil(() -> getWorlds().getCurrentWorld() == 303, 5_000);
            }
        }else if(getWorlds().getCurrentWorld() == 303){
            if(worlds.hop(304)){
                Sleep.sleepUntil(() -> getWorlds().getCurrentWorld() == 304, 5_000);
            }
        }

You could also use a switch statement, or make a nice clean algorithm for the next members worlds in the list, but I'm too lazy to write that.

  • Like 3
Link to comment
Share on other sites

11 hours ago, Naked said:

There's a bunch of things here.

1) Never user a while loop in a script. There's always an alternative.

2) You don't need to explicitly close most interfaces or open a tab for world hopping.

3) You should use if else statements wherever possible.

Realistically, your script should look something like:
 


        log("Time to hop!");
        if(getWorlds().getCurrentWorld() == 302){
            if(worlds.hop(303)){
                Sleep.sleepUntil(() -> getWorlds().getCurrentWorld() == 303, 5_000);
            }
        }else if(getWorlds().getCurrentWorld() == 303){
            if(worlds.hop(304)){
                Sleep.sleepUntil(() -> getWorlds().getCurrentWorld() == 304, 5_000);
            }
        }

You could also use a switch statement, or make a nice clean algorithm for the next members worlds in the list, but I'm too lazy to write that.

Thanks a lot Naked :D , the while loop probably broke my script and it seems to be working perfectly after adjusting to what you sent me. This will keep me away from upcoming obstacles in the future hopefully.

  • Like 1
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...