Jump to content

How to check if bot is cooking


Recommended Posts

Posted

Hello I have some questions regarding the animation when cooking, so I get it when your cooking you're isAnimating() == true but when your character "gets up" to get the other fish it stops animating so my bot spams click the fish on the fire...

Any way on how I can fix this, using a conditional sleep isn't very good because I always have a random number of trouts/salmon in my inventory so this would make the bot slow.

 

 

Thanks in advance!

Posted

Hello I have some questions regarding the animation when cooking, so I get it when your cooking you're isAnimating() == true but when your character "gets up" to get the other fish it stops animating so my bot spams click the fish on the fire...

Any way on how I can fix this, using a conditional sleep isn't very good because I always have a random number of trouts/salmon in my inventory so this would make the bot slow.

 

 

Thanks in advance!

 

Put sleeps like 100,200

  • Like 1
Posted (edited)

Timer class:

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", new Object[] { Long.valueOf(secs / 3600L),
               Long.valueOf(secs % 3600L / 60L), Long.valueOf(secs % 60L) });
   }
}
Then simply implement it like this:

Timer timer = new Timer(4000);
if(myPlayer().isAnimating()){
    timer.reset();
}
if(timer.getElapsed()  > 4000){ 
   //do stuff
}
That should work, just change the 4000 into the time it takes to cook the whole inventory in miliseconds

Actually change the time it takes to cook one and the delay in between, 4000ms should work.

Edited by Vilius
  • Like 3
Posted (edited)

Timer class:

 

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", new Object[] { Long.valueOf(secs / 3600L),
               Long.valueOf(secs % 3600L / 60L), Long.valueOf(secs % 60L) });
   }
}
Then simply implement it like this:

Timer timer = new Timer(4000);
if(myPlayer().isAnimating()){
    timer.reset();
}
if(timer.getElapsed()  > 4000){ 
   //do stuff
}
That should work, just change the 4000 into the time it takes to cook the whole inventory in miliseconds

Actually change the time it takes to cook one and the delay in between, 4000ms should work.

 

how do you stop it?

 

i guess

public void Stop()
{
  start = 0;
}
Edited by The Hero of Time

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...