MadsPH 4 Share Posted December 18, 2017 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 More sharing options...
Koschei 147 Share Posted December 18, 2017 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 More sharing options...
MadsPH 4 Author Share Posted December 18, 2017 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 More sharing options...
Koschei 147 Share Posted December 18, 2017 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 More sharing options...
MadsPH 4 Author Share Posted December 18, 2017 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/ I got it to work now, thank you! Link to comment Share on other sites More sharing options...
dQw4w9WgXcQ 184 Share Posted December 19, 2017 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 More sharing options...
MadsPH 4 Author Share Posted December 19, 2017 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 More sharing options...
dQw4w9WgXcQ 184 Share Posted December 19, 2017 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.