[SOLVED] Salted Earth

I am stuck on Salted Earth like I can’t get my hero to get the coins.

Can you send your code? Also, you can make a topic. If you don’t want to (I don’t think so) can I invite people who can help you?

while True:
    enemy = hero.findNearestEnemy()
    if enemy.type == "munchkin" or enemy.type == "thrower":
        hero.isReady("cleave")
        hero.cleave(enemy)
        hero.attack(enemy)
    coin = hero.findNearestItem()
    # Check the item type to make sure the hero doesn't pick up poison!
    hero.say("I don't think so burl")
    hero.say("no poison")
    # If the item's type is "gem" or "coin":
    if coin:
        # Then move and pick it up:
        hero.move(coin.pos)
        hero.move(coin.pos)
        hero.moveXY(21, 30)
    

Yes I do not care.

Sorry, I can’t help you now. Maybe that guys can help you.

What if the nearest item’s type is poison?
You have to check if the item’s type is “gem” or “coin”, kinda like how you did here:

1 Like

Okay I will try that when I get a chance.

while True:
    enemy = hero.findNearestEnemy()
    if enemy.type == "munchkin" or enemy.type == "thrower":
        hero.isReady("cleave")
        hero.cleave(enemy)
        hero.attack(enemy)
    coin = hero.findNearestItem()
    # Check the item type to make sure the hero doesn't pick up poison!
    hero.say("I don't think so burl")
    hero.say("no poison")
    # If the item's type is "gem" or "coin":
    if item.type == "coin" or item.type == "gem":
        # Then move and pick it up:
        hero.move(item.pos)

It says item is not defined.

My hero is still not gathering any of the coins.

You have to write:

 coin = hero.findNearestItem()
    # Check the item type to make sure the hero doesn't pick up poison!
    hero.say("I don't think so burl")
    hero.say("no poison")
    # If the item's type is "gem" or "coin":
    if coin and coin.type == "coin" or coin.type == "gem":
        # Then move and pick it up:
        hero.move(coin.pos)

So you solved it?

1 Like

Yes I did (20 characters)

Congratulations!

2 Likes

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