duhrealtim Posted November 28, 2023 Share Posted November 28, 2023 import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "Duhrealtim", name = "1-15 WoodCutter", info = "My First Script", version = 0.1, logo = "") public final class Woodcut extends Script { //Areas private final Area treeArea = new Area(3197, 3205, 3180, 3229); private final Area lumbridgeBankArea = new Area(3208, 3218, 3209, 3219); @Override public int onLoop() throws InterruptedException { //Keeps looping if (getInventory().getEmptySlotCount() != 0) { RS2Object tree = getObjects().closest(obj -> obj != null && obj.getName().equals("Tree") && getMap().canReach(obj)); //tree to chop if (!myPlayer().isAnimating()) { if (tree != null) { if (tree.interact("Chop down")) { new ConditionalSleep(5000, 2000) { @Override public boolean condition() throws InterruptedException { return false; } }.sleep(); } } } else if (tree == null) { // if it dont see tree it moves getCamera().toEntity(tree); log("Searching for a tree"); if (getWalking().webWalk(treeArea)) { log("Walking to trees"); new ConditionalSleep(5100, 6100) { @Override public boolean condition() throws InterruptedException { return false; } }; } } } else { log("Inventory Full."); //Walks to bank if (getWalking().webWalk(Banks.LUMBRIDGE_UPPER)) { //What bank it banks at. log("Walking to bank..."); new ConditionalSleep(5000, 1000) { @Override public boolean condition() throws InterruptedException { return true; } }; Entity depoBox = objects.closest("Bank deposit box"); //Opens deposit box and deposits logs. if (depoBox != null) { new ConditionalSleep(2000, 5000) { @Override public boolean condition() throws InterruptedException { return true; } }; if (depoBox.interact("Deposit")) { while (!depositBox.isOpen()) { new ConditionalSleep(2000, 5000) { @Override public boolean condition() throws InterruptedException { return true; } }; } depositBox.depositAllExcept("Bronze axe"); getWalking().webWalk(treeArea); } } } } return 1000; } } My very first script. Still trying to learn how to make it progressive. 3 Quote Link to comment Share on other sites More sharing options...
tmanowen Posted November 29, 2023 Share Posted November 29, 2023 If you can compile it into a .jar for me I'll give it a try and let you know any bugs I come across. Quote Link to comment Share on other sites More sharing options...
duhrealtim Posted November 29, 2023 Author Share Posted November 29, 2023 I can send you a link to the new version of it. I recently changed it to willows and made it powerchop. Start it at draynor next to bank. WoodCutter.jar 1 Quote Link to comment Share on other sites More sharing options...
yfoo Posted November 29, 2023 Share Posted November 29, 2023 Take a look at ConditionalSleep's Api docs again, your usage is incorrect. https://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html. You really need to be overriding condition() and using that to determine when to stop sleeping. Right now you are just sleeping and hoping 5000ms is enough if you CS is returning false. Also every ConditionalSleep where you are just returning true imminently does nothing. For example if (tree.interact("Chop down")) { new ConditionalSleep(5000, 2000) { @Override public boolean condition() throws InterruptedException { return false; } }.sleep(); } I think your intention is to attempt to chop down a tree, then sleep until the tree is chopped down. In which case it should be something like... if (tree.interact("Chop down")) { new ConditionalSleep(5000, 2000) { @Override public boolean condition() throws InterruptedException { // As long condition() resolves to false, Conditional sleep will continue sleeping (if it hasn't been 5seconds yet). // When you are woodcutting, myPlayer().isAnimating() returns true. // I want to my script to wait until the woodcutting animation is complete (meaning the tree is chopped down) // so by !myPlayer().isAnimating() (note the ! in the beginning) // The script will wait until your character stops chopping (aka stops animating) before checking for the next tree. return !myPlayer().isAnimating(); } }.sleep(); } 3 Quote Link to comment Share on other sites More sharing options...
duhrealtim Posted November 29, 2023 Author Share Posted November 29, 2023 Thank you! Quote Link to comment Share on other sites More sharing options...