Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Mushroom Noise

I don’t know what is wrong with my code, I am on the level Mushroom Noise in the desert.

# Defeat the skeleton and open the chest.

def onSpawn (event):
    # Pet should find the health potion (type is "potion"): 
    potion = pet.findNearestByType("potion")
    # and fetch it:
    pet.fetch(potion)
    # Pet should find the gold key (type is "gold-key"):
    item = pet.findNearestByType("goldkey")
    # and fetch it:
    pet.fetch(item)
    pass

# Pet can find more than just items:
skeleton = pet.findNearestByType("skeleton")
pet.on("spawn", onSpawn)

while True:
    if skeleton.health > 0:
        hero.attack(skeleton)
    else:
        hero.moveXY(31, 38)

what is your problem?

never mind, i encountered the worst enemy of coding. AKA misspelling. In the searching for a gold key line there is supposed to be a “-” in between gold and key. I fixed it in the next minute! Thanks for trying to help though.

no problem
:slightly_smiling_face: