April 23, 201510 yr 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, 201510 yr by apa
April 23, 201510 yr I like how you used breakCondition() instead of condition() (the API version of that method), makes more sense IMO. Gj
April 24, 201510 yr ur name I wanna say his name comes from avatar the last air bender but I have no clue.
April 24, 201510 yr sleepTime is not used, for whatever reason.Oh forreal, so your telling me the Api version is bugged
January 5, 201610 yr 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?
January 5, 201610 yr 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(); }
Create an account or sign in to comment