Jump to content

How do i combo eat?


Eskimo231

Recommended Posts

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

Link to comment
Share on other sites

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

 

  • Heart 2
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...