Jump to content

Sleep until animation finished


Booleans YAY

Recommended Posts

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();
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

 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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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