Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • TaskScript GUI Start Button Help


    Xtra

    Recommended Posts

    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

    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

    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

    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

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.