September 27, 20178 yr 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); } }
September 27, 20178 yr 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
September 27, 20178 yr add an else, so when it does see it has an animation, it will go back to sleep for x time, is what id do although never looked into firemaking
September 27, 20178 yr 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.
September 27, 20178 yr Author thanks for the replies guys! I was originally going to do state coding but it seemed a bit advanced for my level ive only been trying to teach my self Java for a few days now. Thanks for the idea for tracking the xp gains, wouldn't have thought of that i'll try it now!
September 27, 20178 yr 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 September 27, 20178 yr by Viston
September 27, 20178 yr Author 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