The level seemed pretty simple, but I can’t get my hero to move to the X if I use hero.gold in the code. I inserted the pet.debug command to tell me the value of hero.gold, and it claims that it’s “undefined”.
I’m posting my stripped down code here. This is an attempt to isolate the problem, not solve the level. Am I doing this hero.gold thing wrong somehow?
# Accumulate 300 gold and escape from the dungeon.
def onSpawn(event):
# Send the pet to walk around the dungeon:
pet.moveXY(20, 58)
pet.debug("hero's gold is " + hero.gold)
pet.moveXY(71, 58)
pet.moveXY(71, 11)
pet.moveXY(20, 11)
pet.moveXY(hero.pos.x, hero.pos.y)
pet.debug("hero's gold is " + hero.gold)
pass
pet.on("spawn", onSpawn)
while True:
if hero.time > 500:
hero.moveXY(50, 34)