Salted Earth Level Help [SOLVED]

Hi, I am having trouble with the code to move can someone help?
Here is my code:

# Ogres are attacking a nearby settlement!
# Be careful, though, for the ogres have sown the ground with poison.
# Gather coins and defeat the ogres, but avoid the burls and poison!

while True:
    enemy = hero.findNearestEnemy()
    if enemy.type == "munchkin" or enemy.type == "thrower":
    item = hero.findNearestItem()
    # Check the item type to make sure the hero doesn't pick up poison!
    # If the item's type is "gem" or "coin":
    if item.type == "coin" or item.type == "gem" :
        # Then move and pick it up:

I just need some help with the code to move and collect the item and I know that the response:

If item:
    Hero.moveXY(item.pos.x, item.pos.y)

is what I may get but how do I have my hero move to the item because when I put x and y it gives an error.

Why did you not move and pick it up?

As I stated above the code when I input the coordinates it states that there is an error.

What error? You are not meant to have capital character there

Wait I had a typo in the x area it was a number.

It works. Thank you. Have a good day.

1 Like

mark the post that helped you the most as solution

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.