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
  • Run TaskNode from AbstractScript


    MadsPH

    Recommended Posts

    I'm trying to roll my own nodes, but I need the MethodContext methods... So I figured I'll extend the TaskNode.

     

    Here is my own node:

    public abstract class HydroNode extends TaskNode {
    
       private HydroScript app;
    
       public HydroNode(HydroScript app) {
          this.app = app;
       }
    
       @Override
       public boolean accept() {
          // override this method
          return true;
       }
    
       @Override
       public int execute() {
          // override this method
          return 0;
       }
     
       public abstract void onPaint(Graphics g);
     
       protected void postAction(String action) {
          app.setAction(action);
       }
    }

    However, when I try to use the methods in MethodContext, I get this error:

    [ERROR]22:10:15: Exception has occurred while running! Please report error to developer if problem persists:
    java.lang.NullPointerException
       at org.dreambot.api.methods.MethodContext.getLocalPlayer(MethodContext.java:182)
       at com.hydrozoa.versatileminer.hydronodes.MiningNode.accept(MiningNode.java:37)
       at com.hydrozoa.dreambotessentials.HydroScript.onLoop(HydroScript.java:66)
       at org.dreambot.api.script.AbstractScript.run(AbstractScript.java:250)
       at java.lang.Thread.run(Unknown Source)
     
    Can I force the AbstractScripts MethodContext on my own nodes? Or can I gain access to the MethodContext in my own nodes otherwise? 
     
    I really want to avoid having to call app#getInventory() every time I need to access the api.

     

    Thank you for reading.

    Link to comment
    Share on other sites

    On your main class, you should be extending TaskScript not Abstract Script if you are trying to run TaskNode on your nodes.

     

    I'm trying to roll my own nodes, but I need the MethodContext methods... So I figured I'll extend the TaskNode.

     

    Here is my own node:

    public abstract class HydroNode extends TaskNode {
    
       private HydroScript app;
    
       public HydroNode(HydroScript app) {
          this.app = app;
       }
    
       @Override
       public boolean accept() {
          // override this method
          return true;
       }
    
       @Override
       public int execute() {
          // override this method
          return 0;
       }
     
       public abstract void onPaint(Graphics g);
     
       protected void postAction(String action) {
          app.setAction(action);
       }
    }

    However, when I try to use the methods in MethodContext, I get this error:

    [ERROR]22:10:15: Exception has occurred while running! Please report error to developer if problem persists:
    java.lang.NullPointerException
       at org.dreambot.api.methods.MethodContext.getLocalPlayer(MethodContext.java:182)
       at com.hydrozoa.versatileminer.hydronodes.MiningNode.accept(MiningNode.java:37)
       at com.hydrozoa.dreambotessentials.HydroScript.onLoop(HydroScript.java:66)
       at org.dreambot.api.script.AbstractScript.run(AbstractScript.java:250)
       at java.lang.Thread.run(Unknown Source)
     
    Can I force the AbstractScripts MethodContext on my own nodes? Or can I gain access to the MethodContext in my own nodes otherwise? 
     
    I really want to avoid having to call app#getInventory() every time I need to access the api.

     

    Thank you for reading.

    Link to comment
    Share on other sites

    I just had to initialize correctly:

    public HydroNode(HydroScript app) {
       this.registerContext(app.getClient());
       this.app = app;
    }

    @ I specifically wanted to roll my own, since TaskScript has some behaviors I don't like.

    Link to comment
    Share on other sites

    I just had to initialize correctly:

    public HydroNode(HydroScript app) {
       this.registerContext(app.getClient());
       this.app = app;
    }

    @ I specifically wanted to roll my own, since TaskScript has some behaviors I don't like.

    Just make your own setup then, don't just try to use some parts of it: it won't work lol.

     

    Tutorial to make your own https://dreambot.org/forums/index.php/topic/5356-videosimple-node-framework-tutorial/

    Link to comment
    Share on other sites

    I just had to initialize correctly:

    public HydroNode(HydroScript app) {
       this.registerContext(app.getClient());
       this.app = app;
    }

    @ I specifically wanted to roll my own, since TaskScript has some behaviors I don't like.

     

     

    shouldnt do this, its better to just make a variable and reference it.  

    Link to comment
    Share on other sites

    shouldnt do this, its better to just make a variable and reference it.  

     

    I know. But for my own sake, it would be nicer to have access through the node (like we usually do with TaskScript anyway), than having to go through a variable multiple times per line. It makes the code unreadable, since (almost) everything I do would go through that single reference.

     

    Anyway, this is similar to TaskNode now. That probably does the same thing, under the hood.

    Link to comment
    Share on other sites

    I know. But for my own sake, it would be nicer to have access through the node (like we usually do with TaskScript anyway), than having to go through a variable multiple times per line. It makes the code unreadable, since (almost) everything I do would go through that single reference.

     

    Anyway, this is similar to TaskNode now. That probably does the same thing, under the hood.

     

    if u create a methodcontext it will have its own instances of the Bank, Walking, etc. https://i.imgur.com/pbY4CYe.png

    Just make your own setup then, don't just try to use some parts of it: it won't work lol.

     

    Tutorial to make your own https://dreambot.org/forums/index.php/topic/5356-videosimple-node-framework-tutorial/

     

    that is topbot api which is static so u dont have to pass context.

    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.