mariotcc 1 Share Posted October 11, 2019 Hi guys! This time I am trying to push my self to make a woodcutting script which does more than "chop & drop". At the moment I am coming into an issue where my charactor for some reason is attempting to cut a tree before he is in the correct location. I am struggling to see what I am doing wrong, as it is my aim to try and figure out as much I can on before asking for help. The area is the trees just outside the GE. If I start the script in the GE, you will notice before the charactor gets to the area, It attempts to cut a tree. How can I make the script only cut when the charactor is the desired area? I have attempted to code it myself but I'm not getting the result. The code is below. Feel free to offer any corrections you can see as it will help me learn for the future! Already I am learning crazy amounts on this forum. I hope this topic will be of help to anyone else experiencing this too. Thank you in advance guys! package Main; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.map.Area; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.interactive.GameObject; @ScriptManifest(author = "Mario", name = "Mario's Varrock Log Chopper", version = 1, description = "Cuts Logs At Varrock And Banks", category = Category.WOODCUTTING) public class main extends AbstractScript { @Override public int onLoop() { Area wc = new Area(3150, 3462, 3163, 3450); GameObject tree = getGameObjects().closest("Tree"); //its around this point where the issue is occuring// if (wc.contains(getLocalPlayer())); else { getWalking().walk(wc.getRandomTile()); sleepUntil(() -> wc.contains(getLocalPlayer()), 10000);} // I am assuming the issue may be this line? if (getLocalPlayer().isAnimating()); else { if (tree != null) ; { tree.interact("Chop Down");} } if(tree.interact("Chop Down")){ sleepUntil(() -> !getLocalPlayer().isAnimating(), 10000); } return Calculations.random(1000, 2000); } } Link to comment Share on other sites More sharing options...
Nex 2542 Share Posted October 12, 2019 @Override public int onLoop() { Area wc = new Area(3150, 3462, 3163, 3450); GameObject tree = getGameObjects().closest("Tree"); if (wc.contains(getLocalPlayer())) { // If ur area contains player do: if (getLocalPlayer().isAnimating()) { // if player is animating: sleep(500); } else { // if not animating if (tree != null && tree.interact("Chop Down")) { // if object isnt null & interaction is succesfull sleepUntil(() -> !getLocalPlayer().isAnimating(), 10000); } } } else { // so else if not in area: getWalking().walk(wc.getRandomTile()); sleepUntil(() -> wc.contains(getLocalPlayer()), 10000); } return Calculations.random(1000, 2000); } Just a correction / explaination using ur code. Didnt test it but assume it will work like this Link to comment Share on other sites More sharing options...
mariotcc 1 Author Share Posted October 12, 2019 @Nex thank you, it seems to have worked. I think i'm logically understanding my mistake, and I need to bare in mind in which {} (order-wise) that I ask for the command, I think I included it too late, so to speak. Thank you for your help! I did have another question but was determined to figure it myself! 😁 Managed to solve that one! Hopefully soon I will be able to release something for the community Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.