Joseph Posted March 6, 2015 Share Posted March 6, 2015 The node interface is Activity public interface Activity { public String status(); public boolean validate() throws InterruptedException; public void run() throws InterruptedException; } The is the Task manager public class TaskTracker { private Activity activeTask; private Activity[] taskList; public TaskTracker(Activity[] taskList) { this.taskList = taskList; } public Activity getActive() throws InterruptedException { if (this.activeTask == null || !this.activeTask.validate()) { for (Activity task: taskList) { if (task != null && task.validate()) { this.activeTask = task; break; } } } return this.activeTask; } } 1 Quote Link to comment Share on other sites More sharing options...
Anonymous Botter Posted March 6, 2015 Share Posted March 6, 2015 This is super similar to what I use and I love this method. 1 Quote Link to comment Share on other sites More sharing options...
Kristoffer OSBot Posted March 6, 2015 Share Posted March 6, 2015 (edited) A priority system would be a good addition to this, other than that, nice snippet. Edited March 6, 2015 by Kristoffer OSBot 1 Quote Link to comment Share on other sites More sharing options...
AresScripts Posted March 6, 2015 Share Posted March 6, 2015 How is this different from what the getState framework does Quote Link to comment Share on other sites More sharing options...
Joseph Posted March 6, 2015 Author Share Posted March 6, 2015 (edited) On 3/6/2015 at 3:56 PM, AresScripts said: How is this different from what the getState framework doesgreat of you to ask. It has the same characteristics. the difference between mine and the getState is that. In getState you are always looping through all the task and grabbing the valid node. But with my Class you will loop through all nodes, grab the valid one. the class will set the valid node as a state in the class. The class will always ref back to the state. If the node is invalid the class will look for a new node. if the node is still active and valid the class will stay with that one node until it is invalid or null. I wanted to add in a void set node but I forgot to do that On top of that I already left my house so I'll change it later. Edit: you won't fully understand it until you actually implement it. for fun implement this frame work to an existing class that supports getState and you will understand what I mean. On 3/6/2015 at 3:55 PM, Kristoffer OSBot said: A priority system would be a good addition to this, other than that, nice snippet.that's on my to do list Edited March 6, 2015 by josedpay Quote Link to comment Share on other sites More sharing options...
Botre Posted March 6, 2015 Share Posted March 6, 2015 Would you mind sharing a small implementation of this? For example; what kind of class would/could implement the Activity interface? 1 Quote Link to comment Share on other sites More sharing options...
AresScripts Posted March 6, 2015 Share Posted March 6, 2015 On 3/6/2015 at 4:51 PM, Botre said: Would you mind sharing a small implementation of this? For example; what kind of class would/could implement the Activity interface? any class that carries out an action like "Mine" and "Drop" 1 Quote Link to comment Share on other sites More sharing options...
Joseph Posted March 6, 2015 Author Share Posted March 6, 2015 (edited) On 3/6/2015 at 4:51 PM, Botre said: Would you mind sharing a small implementation of this? For example; what kind of class would/could implement the Activity interface? It's like a regular node. Create a class, implement activity. Then override the methods. if you have an instance of script within the class then your good to go.Example: Private class Mine implements activity { Override status for name of task Override the boolean. If inventory is not full, mine Override the run method mining event (mentioned to be executed) make sure you have an active script instance } Ill release and example in a few mins Edited March 6, 2015 by josedpay Quote Link to comment Share on other sites More sharing options...
AresScripts Posted March 6, 2015 Share Posted March 6, 2015 On 3/6/2015 at 6:04 PM, josedpay said: It's like a regular node. Create a class, implement activity. Then override the methods. if you have an instance of script within the class then your good to go. Example: Private class Mine implements activity { Override status for name of task Override the boolean. If inventory is not full, mine Override the run method mining event (mentioned to be executed) make sure you have an active script instance } ill try using this when i get home Quote Link to comment Share on other sites More sharing options...
Botre Posted March 6, 2015 Share Posted March 6, 2015 Ok so the class implementing Activity isn't supposed to perform any looping right? Quote Link to comment Share on other sites More sharing options...
Joseph Posted March 6, 2015 Author Share Posted March 6, 2015 On 3/6/2015 at 6:16 PM, Botre said: Ok so the class implementing Activity isn't supposed to perform any looping right? nope. The only looping that actually happens in within the tracker class. Also it only happens once when the method getActivity() i call because of this if statement if (this.activeTask == null || !this.activeTask.validate()) { if that method returns true for any reason it will loop through the array of nodes and grab the new node Quote Link to comment Share on other sites More sharing options...
Joseph Posted March 6, 2015 Author Share Posted March 6, 2015 http://osbot.org/forum/topic/66897-basic-example-of-state-node-scripting/?p=735460 best example Quote Link to comment Share on other sites More sharing options...