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
  • Adding a Treebot option in API


    Michaudretard

    Recommended Posts

    Treebot are build with branch and leaf.

    First we have to create our root task in our main.java file. Then we return where our bot should start. In this case the bot should start at looking if inventory contain the ingredients.

    public class main extends TreeBot {
    
        private final inv_ingredient_check invIngredientCheck = new inv_ingredient_check();
    
        @Override
        public TreeTask createRootTask() {
            return invIngredientCheck;
        }
    
    }

    Branch are boolean build like this. We have the validate state that look for the true or false and we have the return statement (success and the failure).

    In this code we are looking if the bank contains grapes and jug of water. If the bank contains those item we return a success task and move on a branch task again or a leaf that execute code base on the true or false statement. If the bank doesn't contain those item we return the failure task and move on a branch task again or a leaf that execute code base on the true or false statement.
     

    public class bank_contain_ingredient extends BranchTask {
    
        private final inv_contain_something invContainSomething = new inv_contain_something();
        private final is_bank_close isBankClose = new is_bank_close();
    
        @Override
        public boolean validate() {
            return Bank.containsAllOf("Grapes", "Jug of water");
        }
    
        @Override
        public TreeTask successTask() {
            return invContainSomething;
        }
    
        @Override
        public TreeTask failureTask() {
            return isBankClose;
        }
    }

    Leaf execute code base on the returned boolean.

    public class close_bank extends LeafTask {
        @Override
        public void execute() {
            Bank.close();
        }
    }

     

    Link to comment
    Share on other sites

    On 8/29/2020 at 11:06 PM, Michaudretard said:

    Treebot are build with branch and leaf.

    First we have to create our root task in our main.java file. Then we return where our bot should start. In this case the bot should start at looking if inventory contain the ingredients.

    
    public class main extends TreeBot {
    
        private final inv_ingredient_check invIngredientCheck = new inv_ingredient_check();
    
        @Override
        public TreeTask createRootTask() {
            return invIngredientCheck;
        }
    
    }

    Branch are boolean build like this. We have the validate state that look for the true or false and we have the return statement (success and the failure).

    In this code we are looking if the bank contains grapes and jug of water. If the bank contains those item we return a success task and move on a branch task again or a leaf that execute code base on the true or false statement. If the bank doesn't contain those item we return the failure task and move on a branch task again or a leaf that execute code base on the true or false statement.
     

    
    public class bank_contain_ingredient extends BranchTask {
    
        private final inv_contain_something invContainSomething = new inv_contain_something();
        private final is_bank_close isBankClose = new is_bank_close();
    
        @Override
        public boolean validate() {
            return Bank.containsAllOf("Grapes", "Jug of water");
        }
    
        @Override
        public TreeTask successTask() {
            return invContainSomething;
        }
    
        @Override
        public TreeTask failureTask() {
            return isBankClose;
        }
    }

    Leaf execute code base on the returned boolean.

    
    public class close_bank extends LeafTask {
        @Override
        public void execute() {
            Bank.close();
        }
    }

     

    Yeah... this already exists.

     

    Extend TaskScript on your main class and TaskNode on your Nodes

    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.