dunderzutt Posted October 21, 2020 Share Posted October 21, 2020 Script is from HeyImJamie, i'm tryna learn from it. Right now it clicks trees outside the area I selected "(3119, 3221, 3104, 3217);" then it runs back into area and creating a loop of clicking outside area then moving back into area etc etc. Would appreciate any help! thanks! package core; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; 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(name = "Free Woodcutter", version = 1.0, author = "HeyImJamie", info = "", logo = "") public class Main extends Script { @Override public int onLoop() throws InterruptedException { if (shouldBank()) { bank(); } else { cutTree(getTreeName()); } return 100; } private boolean shouldBank() { return getInventory().isFull(); } private void bank() throws InterruptedException { if (!Banks.DRAYNOR.contains(myPlayer())) { getWalking().webWalk(Banks.DRAYNOR); } else { if (!getBank().isOpen()) { getBank().open(); } else { getBank().depositAllExcept(axes -> axes.getName().contains(" axe")); } } } private void cutTree(String treeName) { if (!getTreeArea().contains(myPlayer())) { getWalking().webWalk(getTreeArea()); } else { RS2Object tree = getObjects().closest(treeName); if (!myPlayer().isAnimating() && tree != null) { if (tree.interact("Chop down")) { new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } } } } private Area getTreeArea() { if (getSkills().getDynamic(Skill.WOODCUTTING) >= 60) { return new Area(3203, 3506, 3225, 3497); } else { return new Area(3119, 3221, 3104, 3217); } } private String getTreeName() { if (getSkills().getDynamic(Skill.WOODCUTTING) >= 60){ return "Yew"; } else if (getSkills().getDynamic(Skill.WOODCUTTING) >= 15){ return "Oak"; } else { return "Tree"; } } } Quote Link to comment Share on other sites More sharing options...
FuryShark Posted October 21, 2020 Share Posted October 21, 2020 (edited) 47 minutes ago, dunderzutt said: RS2Object tree = getObjects().closest(treeName); if (!myPlayer().isAnimating() && tree != null) { if (tree.interact("Chop down")) { new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); Add your area when getting the object RS2Object tree = getObjects().closest(getTreeArea(), getTreeName()); Edited October 21, 2020 by FuryShark 1 Quote Link to comment Share on other sites More sharing options...
dunderzutt Posted October 22, 2020 Author Share Posted October 22, 2020 9 hours ago, FuryShark said: Add your area when getting the object RS2Object tree = getObjects().closest(getTreeArea(), getTreeName()); Thanks sir!! Quote Link to comment Share on other sites More sharing options...