Booleans YAY Posted January 4, 2017 Share Posted January 4, 2017 Need some help figuring out how to sleep until the player returns to stand animation. Firemaking can take random lengths of time or failing, so I need to figure out how to sleep till animation is done. new ConditionalSleep(random(2_500)) { @[member=Override] public boolean condition() throws InterruptedException { return !myPlayer().isAnimating(); } }.sleep(); Quote Link to comment Share on other sites More sharing options...
Zerker Posted January 4, 2017 Share Posted January 4, 2017 Don't you need to remove the ! on !myPlayer().isAnimating(); in this case, because you want the sleep to trigger when it is animating. (don't quote me as i don't know wtf im talking about, but maybe try it) Quote Link to comment Share on other sites More sharing options...
Team Cape Posted January 4, 2017 Share Posted January 4, 2017 Don't you need to remove the ! on !myPlayer().isAnimating(); in this case, because you want the sleep to trigger when it is animating. (don't quote me as i don't know wtf im talking about, but maybe try it) No, he wants to stop the sleep when the player is done animating. The issue @OP is that the player doesn't start animating until ~ 1 second after the log is clicked, then he starts animating. You might need to regularsleep for like ~ 1 second before using that conditional sleep, ironically enough. Quote Link to comment Share on other sites More sharing options...
Booleans YAY Posted January 5, 2017 Author Share Posted January 5, 2017 (edited) I tried something like that before and it just comes down to if the player will take longer on a log. Even with my 40 firemaking I sometimes slow down on random logs. Which is why I need to figure out the proper function for sleeping till no animation to prevent this issue. Edited January 5, 2017 by Booleans YAY Quote Link to comment Share on other sites More sharing options...
nyan Posted January 5, 2017 Share Posted January 5, 2017 (edited) basic public static long timeFromMark(long markTime) { return System.currentTimeMillis() - markTime; } also basic but not obvious to most public static boolean doSomething(Script script) throws InterruptedException { script.getSomething().doSomething() // make your fire or whatever long t = System.currentTimeMillis(); while (placeConditionsHere) // while animating for example if (timeFromMark(t) > 3000) // change 3000 to whatever you want break; // you can place a sleep here if you want to use less cpu but it makes no difference imo return false; } i've never used the osbot api for conditional sleeps but my snippet does essentially the same thing and is easily expanded on. good luck! edit: you can modify my snippet to account for the delay before you start animating as well. i'll leave that for you to figure out though :p Edited January 5, 2017 by Shiny Quote Link to comment Share on other sites More sharing options...
Borre Posted January 5, 2017 Share Posted January 5, 2017 (edited) Yeah, sleeping while is animating has been doing weird on some things for me too. You could also check something like, as soon as I gain firemaking xp, continue to the next log. edit: in other words, sleep if you havent gained xp since last log burned Edited January 5, 2017 by Borre Quote Link to comment Share on other sites More sharing options...