Laurow Posted May 12, 2020 Share Posted May 12, 2020 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 Quote Link to comment Share on other sites More sharing options...
Naked Posted May 12, 2020 Share Posted May 12, 2020 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. 3 Quote Link to comment Share on other sites More sharing options...
Laurow Posted May 12, 2020 Author Share Posted May 12, 2020 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 , 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. 1 Quote Link to comment Share on other sites More sharing options...