Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Furnace animation delay

Featured Replies

My script is using a furnace and I am currently using if (!myPlayer().isAnimating()) to check if I am already using the furnace. It works most of the time but it occasionally breaks and tries to restart the crafting while it already is crafting. I am guessing it is because there is a small delay between the smithing animations so the script will think the player is not animating. I have experimented with sleeps and seen into getAnimationDelay() but cannot figure it out.

 

Any help is appreciated :)


public class Timer {

private long period;

private long start;

public Timer(long period) {

this.period = period;

this.start = System.currentTimeMillis();

}

public long getElapsed() {

return System.currentTimeMillis() - this.start;

}

public long getRemaining() {

return this.period - this.getElapsed();

}

public boolean isRunning() {

return this.getElapsed() <= this.period;

}

public void setPeriod(long period) {

this.period = period;

}

public void reset() {

this.start = System.currentTimeMillis();

}

public static String format(long milliSeconds) {

long secs = milliSeconds / 1000L;

return String.format("%02d:%02d:%02d", secs / 3600L,

secs % 3600L / 60L, secs % 60L);

}

}


//method

public boolean isSmithing() {

boolean isSmith = false;

Timer timer = new Timer(1800);

while (timer.isRunning() && !isSmith) {

isSmith = myPlayer().getAnimation() != -1 ? true : isSmith;

}

return isSmith;

}

Edited by Sinatra

  • Author
public class Timer {
   private long period;
   private long start;
   public Timer(long period) {
       this.period = period;
       this.start = System.currentTimeMillis();
   }
   public long getElapsed() {
       return System.currentTimeMillis() - this.start;
   }
   public long getRemaining() {
       return this.period - this.getElapsed();
   }
   public boolean isRunning() {
       return this.getElapsed() <= this.period;
   }
   public void setPeriod(long period) {
       this.period = period;
   }
   public void reset() {
       this.start = System.currentTimeMillis();
   }
   public static String format(long milliSeconds) {
       long secs = milliSeconds / 1000L;
       return String.format("%02d:%02d:%02d", secs / 3600L,
               secs % 3600L / 60L, secs % 60L);
   }
}
//method

public boolean isSmithing() {
    boolean isSmith = false;
    Timer timer = new Timer(1800);
    while (timer.isRunning() && !isSmith) {
         isSmith = myPlayer().getAnimation() != -1 ? true : isSmith;
    }
    return isSmith;
}

 

 

Add a timer

 

Thanks for the help, I'll try this out


Timer timer = new Timer(0);

if (myPlayer().isAnimating())

timer.reset();

if (timer.getElapsed() > MS) {

//do shit

} else {

//w/e

}

Edited by Assnerd

My script is using a furnace and I am currently using if (!myPlayer().isAnimating()) to check if I am already using the furnace. It works most of the time but it occasionally breaks and tries to restart the crafting while it already is crafting. I am guessing it is because there is a small delay between the smithing animations so the script will think the player is not animating. I have experimented with sleeps and seen into getAnimationDelay() but cannot figure it out.

 

Any help is appreciated smile.png

 

Just do a really long ConditionalSleep.

 

For example if you are smelting Gold bars you could do something like:

private final ConditionalSleep SMELTING_SLEEP = new ConditionalSleep(100_000) {

    @Override
    public boolean condition() throws InterruptedException {
            return !getInventory().contains("Gold ore");
    }
};

When you start smelting, you can call:

SMELTING_SLEEP.sleep();

And it will then sleep for up to 100 seconds, or until the inventory no longer contains Gold Ore

Edited by Explv

  • Author

Thanks for all the help guys, figured it out :)

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.