Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • TaskScript


    death dead

    Recommended Posts

    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

    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

    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

    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

    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

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.