apa Posted April 23, 2015 Share Posted April 23, 2015 (edited) I was messing around with the conditional sleep class last night and it was very inconsistent. The deviations, intervals and sleep times seemed to have random effects and I couldn't figure out what the problem was. I ended up pretty much rewriting a conditional sleep and now it works how I expected it should. import org.osbot.rs07.script.MethodProvider; public abstract class BotTimer { int maxSleep; int intervalCheck; int deviation; public BotTimer(int maxSleep, int intervalCheck) { this.maxSleep = maxSleep; this.intervalCheck = intervalCheck; deviation = 0; } public BotTimer(int maxSleep, int intervalCheck, int deviation) { this.maxSleep = maxSleep; this.intervalCheck = intervalCheck; this.deviation = deviation; } public boolean sleep() throws InterruptedException { int randSleep; while (maxSleep > 0 && !breakCondition()) { randSleep = MethodProvider.random(intervalCheck - deviation, intervalCheck + deviation); maxSleep -= randSleep; MethodProvider.sleep(randSleep); } return true; } public abstract boolean breakCondition(); } Using it in your bot would still be the same: new BotTimer(5000, 100) { public boolean breakCondition() { return interfaceOnScreen(465, 21, 25); } }.sleep(); This timer would, at a maximum, call the breakCondition() up to 50 times exactly, or until the interface is shown on screen. Whereas, with ConditionalSleep(5000, 100), it would've execute around 1800 times for me. Edited April 23, 2015 by apa Quote Link to comment Share on other sites More sharing options...
Apaec Posted April 23, 2015 Share Posted April 23, 2015 ur name 9 Quote Link to comment Share on other sites More sharing options...
Precise Posted April 23, 2015 Share Posted April 23, 2015 ur name well... he/she was here first :P 2 Quote Link to comment Share on other sites More sharing options...
apa Posted April 23, 2015 Author Share Posted April 23, 2015 ur name > I'll sell it for $5000 1 Quote Link to comment Share on other sites More sharing options...
Apaec Posted April 23, 2015 Share Posted April 23, 2015 he/she it nah jkjk c: 1 Quote Link to comment Share on other sites More sharing options...
Zebrafon Posted April 23, 2015 Share Posted April 23, 2015 ur name Which translates to "monkey" in Swedish. Quote Link to comment Share on other sites More sharing options...
Botre Posted April 23, 2015 Share Posted April 23, 2015 I like how you used breakCondition() instead of condition() (the API version of that method), makes more sense IMO. Gj Quote Link to comment Share on other sites More sharing options...
Joseph Posted April 23, 2015 Share Posted April 23, 2015 http://prntscr.com/6xcei0 ? Quote Link to comment Share on other sites More sharing options...
Volta Posted April 23, 2015 Share Posted April 23, 2015 well... he/she was here first Oooh rekt 1 Quote Link to comment Share on other sites More sharing options...
FrostBug Posted April 24, 2015 Share Posted April 24, 2015 http://prntscr.com/6xcei0 ? sleepTime is not used, for whatever reason. Quote Link to comment Share on other sites More sharing options...
Twin Posted April 24, 2015 Share Posted April 24, 2015 ur name I wanna say his name comes from avatar the last air bender but I have no clue. Quote Link to comment Share on other sites More sharing options...
Joseph Posted April 24, 2015 Share Posted April 24, 2015 sleepTime is not used, for whatever reason.Oh forreal, so your telling me the Api version is bugged Quote Link to comment Share on other sites More sharing options...
ni562 Posted January 5, 2016 Share Posted January 5, 2016 Since conditionalSleep is no longer in the API documentation, is it preferred to use this method? How well does it work compared to the one from the API? Quote Link to comment Share on other sites More sharing options...
Joseph Posted January 5, 2016 Share Posted January 5, 2016 Since conditionalSleep is no longer in the API documentation, is it preferred to use this method? How well does it work compared to the one from the API? you don't see it in the api documents but it still part of osbot. example call conditional sleep to have it wait if (getInventory().contains(getEnergy())) { getBank().depositAll(); new ConditionalSleep(2000, 100) { @Override public boolean condition() throws InterruptedException { return getInventory().isEmpty(); } }.sleep(); } Quote Link to comment Share on other sites More sharing options...