Jump to content

How do i combo eat?


Recommended Posts

Posted
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

Posted

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
Posted
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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