[SOLVED] Hero.gold undefined in Underground Business

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)

Argh, nevermind, I figured it out. Looks like the Quartz Sense Stone is required for hero.gold to work. That should probably be required equipment for this level.

Funny how you spend an hour trying to solve a problem, and find the answer one minute after posting!

changed title to [SOLVED]

Try telling them this in PM’s next time. :wink:

oka (argh I hate 20 char)

Thanks, I’ll know next time.

It seems kind of stupid for a line of code to not work just because we didn’t equip an item, I literally spent almost an hour looking for the problem with this level