Expels Posted October 22, 2016 Share Posted October 22, 2016 public int onLoop() throws InterruptedException { for (Node n : nodes) { if (n.validate()) { n.execute(); } } return 200; } When I run this, it checks validate and then executes, but after it has finished executing it just stands there? Quote Link to comment Share on other sites More sharing options...
Mr Pro Pop Posted October 22, 2016 Share Posted October 22, 2016 Can you please post your code ? Quote Link to comment Share on other sites More sharing options...
Team Cape Posted October 22, 2016 Share Posted October 22, 2016 public int onLoop() throws InterruptedException { for (Node n : nodes) { if (n.validate()) { n.execute(); } } return 200; } When I run this, it checks validate and then executes, but after it has finished executing it just stands there? how many nodes do you have, and can we see see your validate() statements? also are you sure its not continuously looping in your execute() methods? 2 Quote Link to comment Share on other sites More sharing options...
Expels Posted October 22, 2016 Author Share Posted October 22, 2016 (edited) how many nodes do you have, and can we see see your validate() statements? also are you sure its not continuously looping in your execute() methods? Just one node. public boolean validate() throws InterruptedException { return tree != null && tree.hasAction("Chop down") && !sA.myPlayer().isAnimating() && !sA.inventory.isFull(); Edited October 22, 2016 by Expels Quote Link to comment Share on other sites More sharing options...
Team Cape Posted October 22, 2016 Share Posted October 22, 2016 Just one node. public boolean validate() throws InterruptedException { return tree != null && tree.hasAction("Chop down") && !sA.myPlayer().isAnimating() && !sA.inventory.isFull(); you shouldnt be using a node format for just 1 node. regardless, does it chop 1 tree then just stop working? Quote Link to comment Share on other sites More sharing options...
Expels Posted October 22, 2016 Author Share Posted October 22, 2016 you shouldnt be using a node format for just 1 node. regardless, does it chop 1 tree then just stop working? I have added dropping as well, but yes I chops once and then just stands around. Quote Link to comment Share on other sites More sharing options...
Saiyan Posted October 22, 2016 Share Posted October 22, 2016 Just one node. public boolean validate() throws InterruptedException { return tree != null && tree.hasAction("Chop down") && !sA.myPlayer().isAnimating() && !sA.inventory.isFull(); Why not just return one thing such as the inventory not being full and make it simpler instead of accessing a unnecessary tree variable you created when you don' t need it. e.g for Chop return !sA.getInventory().isFull(); for Drop return sA.getInventory().isFull(); May or may not fix your problem but you don't need to null check something in your validate unless you were planning on doing something like this which I have in my BDK/Gwd (S.getGroundItems().closest(gi -> S.AREA_DRAGONS.contains(gi) && lootList.contains(gi.getName()) && S.getMap().canReach(gi)) != null); Also im assuming your node framework was taken from Booch's tutorial right? Quote Link to comment Share on other sites More sharing options...
Expels Posted October 22, 2016 Author Share Posted October 22, 2016 Why not just return one thing such as the inventory not being full and make it simpler instead of accessing a unnecessary tree variable you created when you don' t need it. e.g for Chop return !sA.getInventory().isFull(); for Drop return sA.getInventory().isFull(); May or may not fix your problem but you don't need to null check something in your validate unless you were planning on doing something like this which I have in my BDK/Gwd (S.getGroundItems().closest(gi -> S.AREA_DRAGONS.contains(gi) && lootList.contains(gi.getName()) && S.getMap().canReach(gi)) != null); Also im assuming your node framework was taken from Booch's tutorial right? If I just check if Inventory is full then it will just spam click. Doing it that way doesn't work anyway. And yes. Quote Link to comment Share on other sites More sharing options...
Saiyan Posted October 22, 2016 Share Posted October 22, 2016 If I just check if Inventory is full then it will just spam click. Doing it that way doesn't work anyway. And yes. You do know validate only toggles the class to activate. If it spams click that's you're interaction code To fix 'spam clicks' use cond sleeps and checks i.e long logCount = getInventory().getAmount("Name of log"); and let's say ur interacting with a tree for eg if(tree.interact("Chop down")) { cond sleep(7500) return getInventory().getAmount("Name of log") > logCount; that should fix spam clicks tbh 1 Quote Link to comment Share on other sites More sharing options...
Expels Posted October 22, 2016 Author Share Posted October 22, 2016 You do know validate only toggles the class to activate. If it spams click that's you're interaction code To fix 'spam clicks' use cond sleeps and checks i.e long logCount = getInventory().getAmount("Name of log"); and let's say ur interacting with a tree for eg if(tree.interact("Chop down")) { cond sleep(7500) return getInventory().getAmount("Name of log") > logCount; that should fix spam clicks tbh It would fix the spam clicking but it still doesn't loop it just stands there after chopping down the tree, there are no errors and the script doesn't stop, so I'm not really sure what is causing it. Quote Link to comment Share on other sites More sharing options...
Saiyan Posted October 22, 2016 Share Posted October 22, 2016 It would fix the spam clicking but it still doesn't loop it just stands there after chopping down the tree, there are no errors and the script doesn't stop, so I'm not really sure what is causing it. Are you still using that tree variable at the top of your class? Could you share more code? It'd really help Your full chop class and ur main class preferably Quote Link to comment Share on other sites More sharing options...
Expels Posted October 22, 2016 Author Share Posted October 22, 2016 Are you still using that tree variable at the top of your class? Could you share more code? It'd really help Your full chop class and ur main class preferably private List<Node> nodes = new ArrayList<Node>(); @[member=Override] public void onStart() { Collections.addAll(nodes, new Chopping(this)); } @[member=Override] public int onLoop() throws InterruptedException { for (Node n : nodes) { if (n.validate()) { n.execute(); break; } } return 200; } Constants c = new Constants(); RS2Object tree = sA.objects.closest("Tree"); public Chopping(Script sA) { super(sA); // TODO Auto-generated constructor stub } @[member=Override] public boolean validate() throws InterruptedException { return !sA.inventory.isFull(); } @[member=Override] public int execute() { if (tree != null) { tree.interact("Chop down"); new ConditionalSleep(1000, 4000) { @[member=Override] public boolean condition() throws InterruptedException { // TODO Auto-generated method stub return !sA.myPlayer().isAnimating(); } }.sleep(); } else { sA.camera.toEntity(tree); } return 200; } } Quote Link to comment Share on other sites More sharing options...
Precise Posted October 22, 2016 Share Posted October 22, 2016 private List<Node> nodes = new ArrayList<Node>(); @[member='Override'] public void onStart() { Collections.addAll(nodes, new Chopping(this)); } @[member='Override'] public int onLoop() throws InterruptedException { for (Node n : nodes) { if (n.validate()) { n.execute(); break; } } return 200; } Constants c = new Constants(); RS2Object tree = sA.objects.closest("Tree"); public Chopping(Script sA) { super(sA); // TODO Auto-generated constructor stub } @[member='Override'] public boolean validate() throws InterruptedException { return !sA.inventory.isFull(); } @[member='Override'] public int execute() { tree = sA.objects.closest("Tree"); if (tree != null) { tree.interact("Chop down"); new ConditionalSleep(1000, 4000) { @[member='Override'] public boolean condition() throws InterruptedException { // TODO Auto-generated method stub return !sA.myPlayer().isAnimating(); } }.sleep(); } else { sA.camera.toEntity(tree); } return 200; } } you only call "tree = sA.objects.closest("Tree");" once when you make an instance of the class. id recommend adding it into the execute method as the first line as above. also, id make it a local variable instead of global. 3 Quote Link to comment Share on other sites More sharing options...
Saiyan Posted October 22, 2016 Share Posted October 22, 2016 you only call "tree = sA.objects.closest("Tree");" once when you make an instance of the class. id recommend adding it into the execute method as the first line as above. also, id make it a local variable instead of global. What i was literally going to say :P 2 Quote Link to comment Share on other sites More sharing options...
Expels Posted October 22, 2016 Author Share Posted October 22, 2016 you only call "tree = sA.objects.closest("Tree");" once when you make an instance of the class. id recommend adding it into the execute method as the first line as above. also, id make it a local variable instead of global. Now it works. Thank you! 2 Quote Link to comment Share on other sites More sharing options...