Jump to content

Sleep until animation finished


Recommended Posts

Posted

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();
Posted

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.

Posted (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 by Booleans YAY
Posted (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 by Shiny
Posted (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 by Borre

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...