August 4, 201312 yr I think I need Enum help.. not sure. You see, I am still somewhat new to scripting, and I do know most of what I need to know for the OSBot API, but I still do not know as much about Java. I am trying to make "FOOD" equal more than one thing.. so I did this: public enum FOOD { Trout, Salmon, Tuna, Lobster, Monkfish, Shark, Swordfish } I am not entirely sure if that's even how to do it, but then I try to do this: Entity food = client.getInventory().getItemForName(FOOD); The red part being an error. I would just like it if someone could point me in the right direction with this. Thank you very much
August 4, 201312 yr you can't use enums for item ids or names. use an int to make every thing easyer. private int state, FOOD_ID, AMOUNT_TO_WITHDRAW; do this on start @Override public void onStart() { try{ FOOD_ID = Integer.parseInt(JOptionPane.showInputDialog("Please enter your food id")); } catch (Exception e){ } try{ AMOUNT_TO_WITHDRAW = Integer.parseInt(JOptionPane.showInputDialog("How many would you like to bring?")); } catch (Exception e){ } } Then you can do Item food = client.getInventory().getItemForId(FOOD_ID); Edited August 4, 201312 yr by NxJr
August 4, 201312 yr This is one way to use enums : public enum FOOD { Trout, Salmon } in your loop : FOOD f = getState(); handleState(f); separate methods : public FOOD getState() { if (inventory.contains(trout)) { return FOOD.Trout; } if (inventory.contains(salmon)) { return FOOD.Salmon; } } public void handleState(FOOD state) { switch (state) { case Trout: do something break; case Salmon: do something break; } Edited August 4, 201312 yr by Skype
August 4, 201312 yr Entity food = client.getInventory().getItemForName(FOOD.Shark.toString()); Will work out, if you wish to keep your current form, but you shouldn't! Your conventions are whack, and if the specific food item has a space in it's name, you're going to run into a little trouble. I'm in a bit of a rush, but I'll leave this here: // enumeration declaration public enum Food { SHARK(1234); private final int id; Food(final int id) { this.id = id; } public int getId() { return id; } } // usage // NOTE - IT MAY NOT BE 'getItemForId', I wouldn't know - I haven't looked at OSBOT since the first/second release Entity food = client.getInventory().getItemForId(Food.SHARK.getId());
August 4, 201312 yr Enums are great, what y'all talking about? public enum Food { TROUT(333, "Trout"), SALMON, TUNA, LOBSTER, MONKFISH, SHARK, SWORDFISH; private int id; private String name; private Food(final int id, final String name) { this.id = id; this.name = name; } public int getId() { return id; } public String getName() { return name; } } Enums are great for storing data + makes your code more clean and organised. Example on how to access the data: selectInventoryOption(client.getInventory().getSlotForName(Food.TROUT.getName()), "Eat");
August 4, 201312 yr /thread >doesn't follow java naming conventions fuck dat shit. When I learned java, the person that taught me used penis and boobs for like all the names. This helped differentiating naming and an actual predefined character such as; public int fucks; vs public int value; I would know that fucks was something you name yourself and value could seem like something that has to be used only when using something called "value" and I don't mean a variable. I mean like int. That is an int. It's not a name I made up. It helped me so yeah.
August 4, 201312 yr /thread >doesn't follow java naming conventions fuck dat shit. When I learned java, the person that taught me used penis and boobs for like all the names. This helped differentiating naming and an actual predefined character such as; public int fucks; vs public int value; I would know that fucks was something you name yourself and value could seem like something that has to be used only when using something called "value" and I don't mean a variable. I mean like int. That is an int. It's not a name I made up. It helped me so yeah. trollololololol enums are so basic, you could learn them without help from somebody else. >,<
August 4, 201312 yr trollololololol enums are so basic, you could learn them without help from somebody else. >,< Very ironic that you say you can learn enumerations on your own when you posted that in a thread about someone asking for help with enumerations...not to mention the video from thenewboston. I guess you consider yourself good scripter since you can figure out something this simple on your own. I wish you the best of luck with your Abyss script.
August 4, 201312 yr Author trollololololol enums are so basic, you could learn them without help from somebody else. >,< Edited August 4, 201312 yr by Fusion