I am stuck on Salted Earth

while True:
    enemy = hero.findNearestEnemy()
    if enemy.type == "munchkin" or enemy.type == "thrower":
        hero.attack(enemy)
    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 == "gem" or "coin":
        
    
        # Then move and pick it up:
    

I can help you 20000000

1 Like

you first need to check if there even is a enemy

2 Likes

why did you make it solved?

1 Like

I got that It is the coins and gems

to check if there is an enemy put if enemy:

1 Like

there isn’t always an enemy right?

1 Like


I need to get the gems.
but I can’t pick them up.

image

do hero.move and item.pos.x and item.pos.y
above

put item.pos.x, item.pos.y inside

I picked up the poison,.

show me your code 2000

while True:
    enemy = hero.findNearestEnemy()
    if enemy.type == "munchkin" or enemy.type == "thrower":
        hero.attack(enemy)
    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 == "gem" or "coin":
        hero.moveXY(item.pos.x, item.pos.y)
    
        # Then move and pick it up:
    

I get the coin but also the poison to

you can check if it is not poison by doing

 if item.type != "poison":

istead of

thank you!!!
20000

is it solved?20000000

yes!!!
20000 car fan

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