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
  • Task framework, but I want it to be more general


    botmaker_01

    Recommended Posts

    I'm fine doing something via Task framework where I have the Loot, Bank, Attack (e.g for fighter script), but what if I want to have a support for supporting multiple locations, e.g. fight at spot A, and continue to spot B? I can do if-else on the navigation, but that doesn't seem to be right thing to do. Is there anything for a state management?
     

    Link to comment
    Share on other sites

    6 hours ago, botmaker_01 said:

    I'm fine doing something via Task framework where I have the Loot, Bank, Attack (e.g for fighter script), but what if I want to have a support for supporting multiple locations, e.g. fight at spot A, and continue to spot B? I can do if-else on the navigation, but that doesn't seem to be right thing to do. Is there anything for a state management?
     

    My script also uses the task framework, with a variable deciding the location.

    Link to comment
    Share on other sites

    There are so many ways to handle this. I would just make a enum of all your supported area's, with a navigation super type variable, and just pass it the appropriate navigation sub-class which handles traversals to specific area. Then just have the user select the supported area. This will be a fair more maintainable approach, easy to add more supported area's, by just adding it to the enum.

    Edited by Chieftain
    Link to comment
    Share on other sites

    12 hours ago, Chieftain said:

    There are so many ways to handle this. I would just make a enum of all your supported area's, with a navigation super type variable, and just pass it the appropriate navigation sub-class which handles traversals to specific area. Then just have the user select the supported area. This will be a fair more maintainable approach, easy to add more supported area's, by just adding it to the enum.

    Can you give a minimalistic example, I'm not 100% sure if I get what you mean. Having enums though seems like a good idea. So in my example I would have a superclass for a set of tasks?

    Link to comment
    Share on other sites

    11 hours ago, botmaker_01 said:

    Can you give a minimalistic example, I'm not 100% sure if I get what you mean. Having enums though seems like a good idea. So in my example I would have a superclass for a set of tasks?

    I am not going to spoon feed you, but here's an example, build on from here. 
     

    enum MonsterArea {
    	LUMBRIDGE_EAST_COWS(new LumbridgeEastCowsNavigation());
    	private AreaNavigation areaNavigation;
    }

     

    Link to comment
    Share on other sites

    On 3/23/2023 at 9:40 AM, Chieftain said:

    I am not going to spoon feed you, but here's an example, build on from here. 
     

    enum MonsterArea {
    	LUMBRIDGE_EAST_COWS(new LumbridgeEastCowsNavigation());
    	private AreaNavigation areaNavigation;
    }

     

    Ok ty bro, now can you explain why you're calling ENUM? that doesn't follow clean code best practices and I have no idea what's happening

    Link to comment
    Share on other sites

    12 hours ago, botmaker_01 said:

    Ok ty bro, now can you explain why you're calling ENUM? that doesn't follow clean code best practices and I have no idea what's happening

    Read up on enum's. They can be used like classes, without object initialization, because we already know the area's we want at compile time. Also what do you mean it does not follow clean code best practices? When you read up on enum's, and practice around with them, it will make sense to you. Hint:

     monsterArea.getNavigation().walk()

    Another hint,

    ComboBox<MonsterArea> monsterAreaBox = new ComboBox<MonsterArea.values()>;

    I am done spoon feeding, good luck.

    Link to comment
    Share on other sites

    • 11 months later...
    On 3/24/2023 at 9:06 PM, botmaker_01 said:

    Ok ty bro, now can you explain why you're calling ENUM? that doesn't follow clean code best practices and I have no idea what's happening

    A little bit late to the party, but ENUM is a very good and clean practice. Lets say a user chooses an option from a ComboBox. Then in other places of your code you want to make decisions or execute action based on the choice of the user. It's a very clean way to use ENUM's for this, since you're always talking in the same way. Besides that you could easily add more area's to your script without modifying much code. 

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