botmaker_01 1 Share Posted March 20, 2023 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 More sharing options...
Aeglen 294 Share Posted March 21, 2023 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 More sharing options...
Chieftain 4 Share Posted March 22, 2023 (edited) 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 March 22, 2023 by Chieftain xyz111 1 Link to comment Share on other sites More sharing options...
botmaker_01 1 Author Share Posted March 22, 2023 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 More sharing options...
Chieftain 4 Share Posted March 23, 2023 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 More sharing options...
botmaker_01 1 Author Share Posted March 24, 2023 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 Gorn 1 Link to comment Share on other sites More sharing options...
Chieftain 4 Share Posted March 25, 2023 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 More sharing options...
boritopalito 0 Share Posted March 7 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now