Xtra 31 Share Posted July 1, 2020 So basically I want to avoid adding the isRunning Boolean to every node, I wondered if there was a way to set the script as isRunning for every node as opposed to adding it to all of them. This is because it seems really inefficient to add it to every one. Wondered if anyone had any tips/ideas? Thanks Link to comment Share on other sites More sharing options...
Bunnybun 181 Share Posted July 1, 2020 Something like this might work? public class Test extends TaskScript { @Override public void onStart() { addNodes(new WaitForGUI()); } public class WaitForGUI extends TaskNode { @Override public boolean accept() { return gui.isRunning(); } @Override public int execute() { addNodes(...); removeNodes(this); return 0; } } } Link to comment Share on other sites More sharing options...
Xtra 31 Author Share Posted July 1, 2020 26 minutes ago, Thal said: Something like this might work? public class Test extends TaskScript { @Override public void onStart() { addNodes(new WaitForGUI()); } public class WaitForGUI extends TaskNode { @Override public boolean accept() { return gui.isRunning(); } @Override public int execute() { addNodes(...); removeNodes(this); return 0; } } } Thanks a lot for the suggestion! However the following produces a NPE [ERROR]00:54:22: Exception has occurred while running! Please report error to developer if problem persists: java.lang.NullPointerException at nodes.WaitForGUI.execute(WaitForGUI.java:19) at org.dreambot.api.script.impl.TaskScript.onLoop(TaskScript.java:84) at org.dreambot.api.script.AbstractScript.run(AbstractScript.java:264) at java.lang.Thread.run(Thread.java:748) Implying that I can't call other nodes from a node..:( package nodes; import mainscript.main; import org.dreambot.api.script.TaskNode; public class WaitForGUI extends TaskNode { private main ctx; @Override public boolean accept() { return main.isRunning; } @Override public int execute() { ctx.addNodes(new BuyNode(), new BankNode(), new WalkToTree(), new MuleNode()); ctx.removeNodes(this); return 300; } } Link to comment Share on other sites More sharing options...
Bunnybun 181 Share Posted July 2, 2020 6 minutes ago, Xtra said: Thanks a lot for the suggestion! However the following produces a NPE [ERROR]00:54:22: Exception has occurred while running! Please report error to developer if problem persists: java.lang.NullPointerException at nodes.WaitForGUI.execute(WaitForGUI.java:19) at org.dreambot.api.script.impl.TaskScript.onLoop(TaskScript.java:84) at org.dreambot.api.script.AbstractScript.run(AbstractScript.java:264) at java.lang.Thread.run(Thread.java:748) Implying that I can't call other nodes from a node..:( package nodes; import mainscript.main; import org.dreambot.api.script.TaskNode; public class WaitForGUI extends TaskNode { private main ctx; @Override public boolean accept() { return main.isRunning; } @Override public int execute() { ctx.addNodes(new BuyNode(), new BankNode(), new WalkToTree(), new MuleNode()); ctx.removeNodes(this); return 300; } } You'll need to pass the script instance when you create the WaitForGUI task public WaitForGUI(main ctx) { this.ctx = ctx; } addNodes(new WaitForGUI(this)); Link to comment Share on other sites More sharing options...
Xtra 31 Author Share Posted July 2, 2020 That's working so far, thanks! 😁😁 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.