q600 Posted January 23, 2019 Posted January 23, 2019 Trying to create a basic script to, chop, and the burn the whole inventory of logs. when I use this code, the script wont even start, but if I remove the burnLogs method, it runs fine? also cannot for the life of me figure out how to how the next tree, not asking to be spoonfed, but if someone wants to hop on discord and help me out that would be great! void cutTree() { if(!getInventory().isFull()) { if(!myPlayer().isAnimating() && tree != null) { tree.interact("Chop Down"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } } } void burnLogs() { if (!"Tinderbox".equals(getInventory().getSelectedItemName())) { if (getInventory().isItemSelected()) { getInventory().deselectItem(); } else { getInventory().interact("Use", "Tinderbox"); } } else if (getInventory().getItem("logs").interact()) { new ConditionalSleep(2000) { @Override public boolean condition() throws InterruptedException { return !myPlayer().isAnimating(); } }.sleep(); } }
Explv Posted January 23, 2019 Posted January 23, 2019 (edited) 11 minutes ago, q600 said: Trying to create a basic script to, chop, and the burn the whole inventory of logs. when I use this code, the script wont even start, but if I remove the burnLogs method, it runs fine? also cannot for the life of me figure out how to how the next tree, not asking to be spoonfed, but if someone wants to hop on discord and help me out that would be great! } else if (getInventory().getItem("logs").interact()) { Isn't it "Logs" not "logs"? That will throw a NullPointerException if the name is incorrect. To hover the next tree you will need to store the current tree you are chopping. Then find the closest tree that is != the tree you're currently chopping, and call hover() on it. Edited January 23, 2019 by Explv
q600 Posted January 23, 2019 Author Posted January 23, 2019 35 minutes ago, Explv said: Isn't it "Logs" not "logs"? That will throw a NullPointerException if the name is incorrect. To hover the next tree you will need to store the current tree you are chopping. Then find the closest tree that is != the tree you're currently chopping, and call hover() on it. Yes, good catch there, and what I mean is that the script wont even start, I don't even get a chance to pause or stop it
Eagle Scripts Posted January 23, 2019 Posted January 23, 2019 Where is `tree` defined? Make sure to move the grabbing of objects, NPCs and whatnot into a method rather than in the body of the class as that will cause your script not to start.
azn2000 Posted January 24, 2019 Posted January 24, 2019 And maybe a real dumb one, but what is your onLoop looking like?