[SOLVED] Hero.gold undefined in Underground Business


#1

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)


#2

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!


#3

changed title to [SOLVED]


#4

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


#5

oka (argh I hate 20 char)


#6

Thanks, I’ll know next time.