death dead 1 Share Posted February 26, 2017 How can we add in priority system? would it be possible for us to create a custom one for like Node framework? Link to comment Share on other sites More sharing options...
Im A Baller 348 Share Posted February 26, 2017 it can be done through just ordering a list of tasks public class Task { public abstract boolean validate(); public abstract boolean execute(); } List<Task> tasks = new ArrayList<>(); Collections.addAll(priority1, priority2, priority3); //assumed each of these priority is a type of task onLoop() { for(Task t: tasks) if(t.validate()) return t.execute(); } now since each task is listed by priority in the arraylist, it will check each in order of priority. these are the (very) barebones on which basically every task-based script works. gl Link to comment Share on other sites More sharing options...
7804364 231 Share Posted February 26, 2017 Can easily be done, first add priority to your abstract class (node class) public int priority () { return 0; } then on your actual task classes add @Override public int priority() { return 1; } (this will be where you set which task has priority) then finally in your main class put all the tasks in an array, then sort those tasks by priority Link to comment Share on other sites More sharing options...
Dreamlicker 750 Share Posted February 26, 2017 There is no reason to sort your nodes. TaskNode itself has a priority method. Your nodes will be executed based on their priority. Just override the method and return the priority level you wish the node to have. https://dreambot.org/javadocs/org/dreambot/api/script/TaskNode.html Link to comment Share on other sites More sharing options...
death dead 1 Author Share Posted February 26, 2017 Can easily be done, first add priority to your abstract class (node class) public int priority () { return 0; } then on your actual task classes add @Override public int priority() { return 1; } (this will be where you set which task has priority) then finally in your main class put all the tasks in an array, then sort those tasks by priority Yes, the problem is how can I sort them by priority? this is what I wanted . it can be done through just ordering a list of tasks public class Task { public abstract boolean validate(); public abstract boolean execute(); } List<Task> tasks = new ArrayList<>(); Collections.addAll(priority1, priority2, priority3); //assumed each of these priority is a type of task onLoop() { for(Task t: tasks) if(t.validate()) return t.execute(); } now since each task is listed by priority in the arraylist, it will check each in order of priority. these are the (very) barebones on which basically every task-based script works. gl Ok, thanks There is no reason to sort your nodes. TaskNode itself has a priority method. Your nodes will be executed based on their priority. Just override the method and return the priority level you wish the node to have. https://dreambot.org/javadocs/org/dreambot/api/script/TaskNode.html As I said I wanted to know how to make a custom one to get better into scripting anyways thanks . Link to comment Share on other sites More sharing options...
Dreamlicker 750 Share Posted February 26, 2017 Yes, the problem is how can I sort them by priority? this is what I wanted . Ok, thanks As I said I wanted to know how to make a custom one to get better into scripting anyways thanks . Extending TaskNode to create your custom version is likely your best solution. If you can detail what you want to be different from the current implementation, more help can be given. Link to comment Share on other sites More sharing options...
death dead 1 Author Share Posted February 27, 2017 Extending TaskNode to create your custom version is likely your best solution. If you can detail what you want to be different from the current implementation, more help can be given. Ok thank you now, i will work with TaskNode. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.