Mad 86 Share Posted May 16, 2016 Got bored and made a quick tutorial on the node framework for scripting. https://streamable.com/449z Rate/Hate pls Link to comment Share on other sites More sharing options...
JanDeBruin 11 Share Posted May 16, 2016 Nice TopBot API Link to comment Share on other sites More sharing options...
pharaoh 130 Share Posted May 20, 2016 thanks for this cool guide i will use it in my scripts edit: can i add u on skype for some quick questions Link to comment Share on other sites More sharing options...
heatslinger 0 Share Posted May 23, 2016 I have been trying to find a good explanation of nodes and how they work. You explained it so simply, thanks! Link to comment Share on other sites More sharing options...
Big Buddha 6 Share Posted June 29, 2016 Nice and clean. ++ Link to comment Share on other sites More sharing options...
PancakePunche 0 Share Posted September 17, 2016 This is great, this is exactly what I need for my script! Thanks! So one question, inside the class file that's implementing the node method when I call Inventory.isFull, it gives me an error informing me that .isFull cannot be referenced from a static context? Link to comment Share on other sites More sharing options...
spectrewiz 0 Share Posted September 18, 2016 This is great, this is exactly what I need for my script! Thanks! So one question, inside the class file that's implementing the node method when I call Inventory.isFull, it gives me an error informing me that .isFull cannot be referenced from a static context? Hey, I might have an answer for you. Try passing in a reference of the main script to the constructor of each node so that you can use stuff like getInventory() or getCombat(), or whatever you need. Here's how I'm doing it on my first script: Main (example): public class Main extends AbstractScript { private final Node[] nodes = {new CutTree(this), new Bank(this)}; //"this" passes in the script's reference to each node @Override public int onLoop() { for (Node node : nodes) { //loop through the nodes and check if any are valid final Node n = node; if (n.validate()) { //find valid node and execute it n.execute(); break; //break so it doesn't try to do two things at once } } return Calculations.random(300, 400); } } CutTree (example): public class Bank implements Node { private Main ctx; //script reference public Bank(Main ourScript) { //constructor of the Bank class this.ctx = ourScript; //set the reference in the constructor } @Override public boolean validate() { return !ctx.getInventory().isFull(); //bank when the inventory is full } @Override public void execute() { //BANK CODE } } Now whenever you want to access stuff like getInventory(), you just use ctx.getInventory(). "ctx" is just an abbreviation for context. Note: I haven't actually tested anything yet, I'm just playing around with coding at this point, but I hope think that the above stuff should work. Hope this helps you EDIT: I tested it, it works Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.