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
  • Try asking for help in the chatbox
  • Question about readability and efficiency


    luminlumin
     Share

    Recommended Posts

    When making task based scripts, is it more efficient to have a class for everything? For example, would it be more efficient to create a GoToBank task and then a Bank task to handle the actual banking, or is it the same thing as handling walking and banking in 1 class?

     

    Sorry if this is a stupid question, what I really want to know is if there is a performance hit (even if it's unnoticeable to the human eye) when you have more tasks, or is it better to separate it all since it's task based anyways..

     

    Edit: To reiterate, right now, I could do addNode(new MineTask(), new BankTask()); where MineTask and BankTask also handle walking to and from places. I can also do new GoToMine(), new Mine(), new GoToBank(), new Bank()); 

     

    Which is the more acceptable way?

    Edited by luminlumin
    Link to comment
    Share on other sites

    I would just do something like

     

    if (atbank) {

    bank

    } else {

    walktobank

    }

     

    Thanks, I just decided to separate them all into different nodes, it makes it easier to understand at least for me. 

    Link to comment
    Share on other sites

    For actual efficiency, I'm honestly unsure how much of a hit it would make. I'm pretty sure there are ways to increase performance (see: https://en.wikipedia.org/wiki/Software_design_pattern )

    But for the most part it's for readability and general ease of updating/adding features I think.

     

    Here's the thing though, see this part:

    public int priority() {
            return 1;
        }
    

    I'm not sure if every class needs its own priority, but the tutorial I followed had that, and so I have a priority for all of my tasks, however, I can see it becoming an issue if you're working on a huge script, not 5 or 6 classes but maybe 80 or 90 different tasks (just for example).

     

    So, why is priority even needed if we are calling new nodes anyways to be executed in our main class?

    Link to comment
    Share on other sites

    Here's the thing though, see this part:

    public int priority() {
            return 1;
        }
    

    I'm not sure if every class needs its own priority, but the tutorial I followed had that, and so I have a priority for all of my tasks, however, I can see it becoming an issue if you're working on a huge script, not 5 or 6 classes but maybe 80 or 90 different tasks (just for example).

     

    So, why is priority even needed if we are calling new nodes anyways to be executed in our main class?

    Each node class will nee its own priority, and I think you can use it if 2 nodes accept using the same method but you want one to run before the other I'm not certain though.

    Edited by swift
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • 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.