Jump to content

Keeps lighting logs while im already lighting


Recommended Posts

Posted

hi ive been trying to work on my first script, which just checks for logs on the ground and lights them. however the problem is that when the script starts to light a fire and the animation comes on, the loop keeps repeating itself over and over without stopping so it keeps lighting the same log over and over before it has time to even light. i know there is something to do with player animations but im new to java so im a bit stuck. (dont mind the sleep times)

source - 

package org.Hello.Sebby;

import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;




import java.awt.*;

@ScriptManifest(name = "Skeleton", logo ="", info ="Script Info", version = 0.1, author ="08egans")
public class skeleton extends Script{

    public void onStart(){
        log("Our Script has started");

    }

    public int onLoop() throws InterruptedException {

        GroundItem item =   getGroundItems().closest("Logs");
        if(!myPlayer().isAnimating()) {
            item.interact("Light");
            sleep(random(2000, 3000));

        }

        return random(2000, 1800);
    }
    public void onExit(){
        log("Script has stopped");
    }
    public void onPaint(Graphics g){

    }
    public void onMessage(String s){
        log("on Message: " + s);
    }
}
  • Like 1
Posted

the firemaking animation is weird,it stops animating regularly (when you stand up it actually stops the animation before starting again meaning !myPlayer().isAnimating() will think its not animating, unlike during fishing/wc where it doesn't stop the animation), its not the best way to check, honestly I would try something simpler as your first script

Posted

First off I would really recommend looking up a tutorial and trying to work on it using state based logic.

 

But anyways, given your current code with the intention of trying to do what you want to do,

 

I would just keep track of your xp gains. If you haven't gained exp since the last time you tried to light a log, then presumably you're not done burning that log yet, so don't try to light another one.

Posted (edited)

if (myPlayer().isAnimating()) { //if we are animating
                *LONG VARIABLE TO STORE THE TIME* = System.currentTimeMillis(); //Grabs the time

} else if (System.currentTimeMillis() > (*THE VARIABLE U CREATED* + 5000)) { //If we are not animating, and 5 seconds has passed without us animating, then do stuff.

//Do your stuff here such as lighting the log

};

 

Reference -> 

 

Edited by Viston
  • Like 1
Posted
4 hours ago, Viston said:

if (myPlayer().isAnimating()) { //if we are animating
                *LONG VARIABLE TO STORE THE TIME* = System.currentTimeMillis(); //Grabs the time

} else if (System.currentTimeMillis() > (*THE VARIABLE U CREATED* + 5000)) { //If we are not animating, and 5 seconds has passed without us animating, then do stuff.

//Do your stuff here such as lighting the log

};

 

Reference -> 

Thank you for the help! :)

 

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