Salted earth please help

oh I get it but its just starting labeling the coin, "coin, gem, item, bottle " though

1 Like

1 Like

Looking at your code, delete lines 24 and 25. You don’t want to do anything if there’s a bottle, just wait for it to disappear. Also delete line 16.

Lines 10, 17, 18 and 19 are all labelling the nearestItem as (respectively) item, gem, coin and bottle. You only need the first one of these, delete the others if you want tidier code.

2 Likes

wait what do I do in if item.type == "coin" or item.type == "gem": Then?

1 Like

this is my code now:

1 Like

The line you had in before inside the if statement was good. Put this back in:

       hero.moveXY(itemX, itemY)
1 Like

but then the hero attack the burl and the burl kills the hero

1 Like

Wow, this is complicated :wink:

I think it might be lines 8 and 9 that are the problem now. Try deleting them?

1 Like

Thanks so much jka2706! I finished it!

1 Like

Well done :grinning:.

1 Like

sorry it worked, but when I press submit it going to attack the enemy, but there was a bottle there and it ran into the bottle. Then it died.

1 Like

oh nevermind I put my ring on hat commands “wait” so i put it and now it works. Thanks though

2 Likes

thanks for the like jka2706!

1 Like
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 gem or coin":
        
        # Then move and pick it up:
        
what do I do?
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 gem or coin":
        itemy = hero.distanceTo(item)
        itemx = hero.distanceTo(item)
        # Then move and pick it up:
        hero.moveXY(itemx, itemy)
        
```I'm heavly stuck help I keep dying to pioson

This is not how to write if the item type is a gem or coin
you didn’t pick the items up either

Read these two carefully.
Lydia

thank you, that is going to help alot

I’m still stuck, it doesn’t work, I keep dying to a poison vile

what is your code
20 chars