atoo Posted November 19, 2015 Posted November 19, 2015 so basicly i think this is the problem with my script, im trying to add a YEW location to chop at aswell but when i add my yew thingies my script stops working. (no its not because of the update, my script works fine without the YEW added) private State getState() { if (dialogues.isPendingContinuation()) return State.LEVEL; else if (willowArea.contains(myPlayer())) if(yewArea.contains(myPlayer())) < problem return State.CHOP; return State.IDLE; }
Volta Posted November 19, 2015 Posted November 19, 2015 so the 2 areas, willow area and yew area are overlapping? with the yew area being inside of the willow area? 1
Joseph Posted November 19, 2015 Posted November 19, 2015 You have 3 if or else if statements that need there own return. And a default return for the methods. So you need 4 return types 1
Apaec Posted November 19, 2015 Posted November 19, 2015 Uh If you're a little lost, i'd recommend putting curly brackets around each if statement, when you're learning it's an easy way to get confused if you leave them out. (otherwise the if statement only applies to the next line) Format it, look at it, and see if you can figure out what you've done wrong apa 1
FrostBug Posted November 19, 2015 Posted November 19, 2015 private State getState() { if (dialogues.isPendingContinuation()) { return State.LEVEL; } else if (willowArea.contains(myPlayer()) || yewArea.contains(myPlayer())) { return State.CHOP; } return State.IDLE; } ?? 1
atoo Posted November 19, 2015 Author Posted November 19, 2015 (edited) ok so i manange to fix the "freeze" on my script, but now it just jumps onto my anti ban and loops it. I will try more and post results! private State getState() { if (dialogues.isPendingContinuation()) { return State.LEVEL; } else if (willowArea.contains(myPlayer()) || yewArea.contains(myPlayer())) { return State.CHOP; } return State.IDLE; } ?? Still gets stuck on "loading script" trying out various things atm so the 2 areas, willow area and yew area are overlapping? with the yew area being inside of the willow area? Not sure at the moment Edited November 19, 2015 by atoo
MalikDz Posted November 19, 2015 Posted November 19, 2015 (edited) this : else if (willowArea.contains(myPlayer())) if(yewArea.contains(myPlayer())) is equivalent to this : else if (willowArea.contains(myPlayer()) && yewArea.contains(myPlayer())) There's some logic flaws in this code, I mean how can the player be in 2 differents area at the some moment?? try this : else if (willowArea.contains(myPlayer()) || yewArea.contains(myPlayer())) Edited November 19, 2015 by MalikDz 1
atoo Posted November 19, 2015 Author Posted November 19, 2015 (edited) thatst what frosty posted, bot still freezes the problem is definetly here switch(getState()) { case LEVEL: dialogues.clickContinue(); break; case CHOP: tree = objects.closest(willowArea, "Willow"); tree = objects.closest(yewArea, "Yew"); //Broken? Edited November 19, 2015 by atoo
MalikDz Posted November 19, 2015 Posted November 19, 2015 (edited) thatst what frosty posted, bot still freezes the problem is definetly here switch(getState()) { case LEVEL: dialogues.clickContinue(); break; case CHOP: tree = objects.closest(willowArea, "Willow"); tree = objects.closest(yewArea, "Yew"); //Broken? 1. Start by writing the right name of the tree you want to interact with , im sure the tree name is "Yew tree" and not "tree" 2. You are assigning a new value to the "tree" var and you're not even using it anywhere and then directly after you just reassign a new value to it ? flawed logic 3. Can you post more code , that snippet doesn't tell us much? Edited November 19, 2015 by MalikDz 1
Bobrocket Posted November 20, 2015 Posted November 20, 2015 (edited) With your object code: You may get a NullPointerException if the tree is too far away, which will break your code and make you cry If a tree is too far away, but not null, you may not be able to interact with it. You will need to walk up to it first. if (yewTree != null && yewTree.exists() && getMap().distance(yewTree) <= 11) //valid yew tree EDIT: shameless self plug here, using OmniAPI might shrink your code a little: Entity yewTree = getEntityFinder().findClosest("Yew", (tree) -> (yewArea.contains(tree.getPosition()) && getMap().distance(tree) <= 11)); yewTree.interact("Chop-down"); //100% safe to do this, as OmniAPI returns empty objects instead of null Edited November 20, 2015 by Bobrocket 2
atoo Posted November 20, 2015 Author Posted November 20, 2015 With your object code: You may get a NullPointerException if the tree is too far away, which will break your code and make you cry If a tree is too far away, but not null, you may not be able to interact with it. You will need to walk up to it first. if (yewTree != null && yewTree.exists() && getMap().distance(yewTree) <= 11) //valid yew tree EDIT: shameless self plug here, using OmniAPI might shrink your code a little: Entity yewTree = getEntityFinder().findClosest("Yew", (tree) -> (yewArea.contains(tree.getPosition()) && getMap().distance(tree) <= 11)); yewTree.interact("Chop-down"); //100% safe to do this, as OmniAPI returns empty objects instead of null Seems logical, I will do the same code for willow aswell. Just need to get my laptop up first
atoo Posted November 20, 2015 Author Posted November 20, 2015 Okay i dont know if there was an RS update but my bot does not click anymore (when hoving over the trees)