mariotcc 1 Share Posted September 28, 2019 Hi guys I am currently workin on a simple woodcutting script, so far it loops well, managed to get 1-23 woodcutting with no problem at all. To expand on this script and make it better, I would like to implement a random sleep time after cutting each log, as I feel it would make sense and appear more realistic. I will show my code with my mistake as it may show you guys where I am trying to add the sleep function logically (may be wrong place but i think it will help understand my thought process) package main; import org.dreambot.api.methods.map.Area; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.wrappers.interactive.GameObject; @ScriptManifest(author = "Mario", name = "firstScript", version = 2, description = "First Demo!", category = Category.MONEYMAKING) public class main extends AbstractScript { @Override public void onStart() { log("Script has now Started!"); log("Enjoy My Demo Script!"); } @Override public int onLoop() { Area cuttingArea = new Area(3138,3257,3157,3239); if (!getLocalPlayer().isAnimating()) { if(cuttingArea.contains(getLocalPlayer())); else{ getWalking().walk(cuttingArea.getRandomTile()); } if(getInventory().isFull()){ getInventory().dropAllExcept("Small fishing net"); } else{ GameObject tree = getGameObjects().closest("Tree"); if (tree != null){ tree.interact("Chop Down"); log("Cutting Tree"); } if(tree.interact("Chop Down")){ int countLog = getInventory().count("logs"); sleepUntil(() -> getInventory().count("logs") > countLog, 10000); sleep((int) (Math.random() * 7002)); } } } return 1500; } @Override public void onExit() { log("The Script Has Ended!"); } } Thank you in advance guys! any help will be greatly appreciated! Link to comment Share on other sites More sharing options...
mariotcc 1 Author Share Posted September 28, 2019 Quote 2 minutes ago, Infidel said: sleep(1000); sleep(Calculations.random(1000,1300); sleepUntil(() -> !getLocalPlayer().isAnimating(), 4000); sleepWhile(() -> getLocalPlayer().isAnimating(), 4000); thank you mate! appreciate your time and help! I am sure this will help other noobs like myself. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now