Jammer Posted November 24, 2017 Share Posted November 24, 2017 I've seen people using if statements like: if(Enemy.interact("Attack"){sleep;} instead of just interacting and then sleeping. I understand that they achieve the same thing but I don't understand how I can use a non boolean value in an if statement or does it become a boolean after executing it? Quote Link to comment Share on other sites More sharing options...
Night Posted November 24, 2017 Share Posted November 24, 2017 When people do that it means the method returns a boolean based on success. You can use this success boolean to sleep ONLY if the action was successful - this means that instead of sleeping after a misclick, you'll just try again immediately like a human would. 1 Quote Link to comment Share on other sites More sharing options...
Jammer Posted November 24, 2017 Author Share Posted November 24, 2017 2 minutes ago, Night said: When people do that it means the method returns a boolean based on success. You can use this success boolean to sleep ONLY if the action was successful - this means that instead of sleeping after a misclick, you'll just try again immediately like a human would. I see, thanks man Quote Link to comment Share on other sites More sharing options...
liverare Posted November 24, 2017 Share Posted November 24, 2017 Enemy.interact("Attack") That returns a boolean. If that boolean value is true, then the bot successfully interacted with the enemy. If that boolean value is false, then the bot failed. The sleep is inside that IF statement so that you only sleep if you were successful. Because otherwise, you're going to be needlessly delaying yourself. 1 Quote Link to comment Share on other sites More sharing options...
roguehippo Posted December 4, 2017 Share Posted December 4, 2017 I recently attempted to uploaded a script, and was told that i needed to use conditional sleeps. is this what he was referencing? (because all my sleeps are wrapped in a condition as shown above) im just a little confused. Quote Link to comment Share on other sites More sharing options...
Theorems Posted December 4, 2017 Share Posted December 4, 2017 (edited) 17 minutes ago, roguehippo said: I recently attempted to uploaded a script, and was told that i needed to use conditional sleeps. is this what he was referencing? (because all my sleeps are wrapped in a condition as shown above) im just a little confused. were you using sleepWhile or sleepUntil ? Those are conditional sleeps as far as I'm aware. edit: actually that's from another api I think osbot uses conditionalSleep() new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isUnderAttack(); } }.sleep(); Edited December 4, 2017 by Theorems Quote Link to comment Share on other sites More sharing options...
roguehippo Posted December 4, 2017 Share Posted December 4, 2017 7 minutes ago, Theorems said: where you using sleepWhile or sleepUntil ? Those are conditional sleeps as far as i'm aware. edit: actually that's from another api I think osbot uses conditionalSleep() new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isUnderAttack(); } }.sleep(); ahhh, i was not doing this. so this will sleep for 5000 millisecond if the player is under attack? may i ask what the .sleep() is doing in this example? Quote Link to comment Share on other sites More sharing options...
Theorems Posted December 4, 2017 Share Posted December 4, 2017 Just now, roguehippo said: ahhh, i was not doing this. so this will sleep for 5000 millisecond if the player is under attack? may i ask what the .sleep() is doing in this example? I believe that sleeps until the condition myPlayer.isUnderAttack() is true or the 5000 milliseconds has expired. Not actually sure about the .sleep() I copy pasted that example from the open afk splasher script, maybe take a look at that code. Quote Link to comment Share on other sites More sharing options...