Eskimo231 Posted September 23, 2020 Share Posted September 23, 2020 Hi how can i make my character combo eat swordfish and pizza? private String food ="Swordfish"; private String food2 ="Anchovy Pizza"; if (myPlayer().getHealthPercent()== 100) if (getInventory().contains(food,food2)) { log("Contains" + food + food2); } if (getInventory().interact("Eat",food,food2));{ log("Eating Swordfish and Pizza"); } when i use this code it will only eat food2 i have been thinking about isAnimating since animation each has its own id, i.e; eating has a id of 829 but since its a boolean type it will not differentiate between id values and only return true or false for any animation made? i now want check for; if swordfish has been eaten/interacted with then eats pizza just learned java a few hours ago still trying to figure out how to write the code for this could someone push me in the right direction thanks in advance Quote Link to comment Share on other sites More sharing options...
Explv Posted September 23, 2020 Share Posted September 23, 2020 getInventory().contains(item1, item2) Returns true if either item1 or item2 is in the inventory. getInventory().interact("Eat", item1, item2) Uses the interaction "Eat" on either item1 or item2 depending on which item it finds in the inventory first. If you want to eat a Swordfish followed by a Pizza, you need to be explicit in your logic, i.e If not eaten swordfish Then eat swordfish Else Eat pizza To track whether you have eaten a swordfish, just store a boolean value in a variable, e.g. hasEatenSwordfish, and set it to true when the "Eat" interaction on the swordfish is successful. Set it back to false when you eat the pizza 2 Quote Link to comment Share on other sites More sharing options...
DianaParr Posted September 23, 2020 Share Posted September 23, 2020 wow, actually useful, thanks, buddy 1 Quote Link to comment Share on other sites More sharing options...
Eskimo231 Posted September 24, 2020 Author Share Posted September 24, 2020 13 hours ago, Explv said: getInventory().contains(item1, item2) Returns true if either item1 or item2 is in the inventory. getInventory().interact("Eat", item1, item2) Uses the interaction "Eat" on either item1 or item2 depending on which item it finds in the inventory first. If you want to eat a Swordfish followed by a Pizza, you need to be explicit in your logic, i.e If not eaten swordfish Then eat swordfish Else Eat pizza To track whether you have eaten a swordfish, just store a boolean value in a variable, e.g. hasEatenSwordfish, and set it to true when the "Eat" interaction on the swordfish is successful. Set it back to false when you eat the pizza omg didnt think about storing values like that ! i can see that this will open alot of things in my coding Thank you so much 1 Quote Link to comment Share on other sites More sharing options...