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)
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.
J’ai moi aussi trouver mon erreur. Je le partage, comme ça si une autre personne est embeté, je pourrai aider a mon tour.
Donc a la ligne 9, j’ai commencé par écrire:
gold-key = pet.findNearestByType(“gold-key”)
Noter comme ça, ça equivalait a “gold” qui soustrait a “key”. J’ai simplement enlevé le (-).
Voila je referme le post