death dead 1 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?
Im A Baller 348 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
7804364 231 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
Dreamlicker 750 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
death dead 1 Author 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 .
Dreamlicker 750 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.
death dead 1 Author 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.