-
Posts
23 -
Joined
-
Last visited
Recent Profile Visitors
885 profile views
Gorn's Achievements
-
fuck tree branch. just my opinion
-
Gorn reacted to a post in a topic: Task framework, but I want it to be more general
-
I WROTE MYSELF INTO A PICKLE MORTY
-
Gorn reacted to a post in a topic: Bunch of error in the code
-
Gorn reacted to a post in a topic: Bunch of error in the code
-
Gorn reacted to a post in a topic: Is there a way of counting the rune in runepouch?
-
And my suggestion in the first post is bad so don't write it like that. Like what is the items "type"? it's very vague. Is shield and defender the same item type? If so then we are really just talking about item slots. Dreambot has this enum built in so you don't even have to write it. https://dreambot.org/javadocs/org/dreambot/api/methods/container/impl/equipment/EquipmentSlot.html So the function shoud probably look something like this String GetBestArmorPiece(EquipmentSlot slot){ switch(slot){ case AMULET: GetBestAmulet(); break; etc. } } idealy it would return Class<Item> or maybe id of the item
-
Replacing strings with enums is normal but you are doing it the other way, turning enums into strings. I think they only added it in as last resort, if you wrote yourself into a pickle and need an ugly way out. Definetly not the default way of using enums. Having enums for the items is fine but keep it simple, one enum for each item slot. That should work on small to mid size scripts just fine. If u actualy want a better way then start by making a better database. I was asking about something here some time ago and yeeter pointed me to this project. Somebody already made a databse of all osrs items. https://github.com/osrsbox/osrsbox-db/tree/master/docs items-complete.json is the full database. You definetly want to trim it down somehow just to items your bots will actualy encounter because it's over 20000 entries. Maybe make some automatic system for that 😉 I'm only mentioning this because u said u wanted a better way. I think this is the better way. But honestly just having enums for the items and then one extra for setting the type like I suggested in the first post is fine. Maybe ditch the convention and just name them like the actual items are named, so u don't have to format the string.
-
Diggington reacted to a post in a topic: How to pass enums in Java?
-
No you don't pass enums like that because enums are static. But the problem u have here isnt with enums. All the enums u showed here are just lists of strings anyway (that's how u are using them). This item system is just bad so creating anything in it is gonna be a headache. Like how do you represent for example mithril gloves in this? enum + enum? One enum for mithril and one enum for gloves and then turn it into a string to get mithril gloves lol. I hope u see the problem here isnt passing around enums. Not even talking about all that extra string formatting which is cancer because it needs memory allocation.
-
What do you want to pass into GetBestArmourPiece? It woud have to get a value that sets the type. private static String GetBestArmourPiece(itemTypes itemType){ String bestItem = ""; switch(itemType){ case HELMET: bestItem = GetBestHelmet(); break; case BODY: bestItem = GetBestBody(); break; . . . } return bestItem; }