Error in Underground Business 1

Hi, even with collecting all items around map my total gold only is 275, but to pass level 300 is needed.
What am I doing wrong?
Here is my code:

 # Accumulate 300 gold and escape from the dungeon.

def onSpawn(event):
    pet.moveXY(21, 11)
    pet.moveXY(71, 11)
    pet.moveXY(71, 57)
    pet.moveXY(21, 57)
    pet.moveXY(20, 35)
    pet.moveXY(hero.pos.x, hero.pos.y)

pet.on("spawn", onSpawn)

while True:
    # Guard peasants:
    enemy = hero.findNearestEnemy()
    item = hero.findNearestItem()
    if enemy:
        hero.attack(enemy)
    if item:
        hero.moveXY(item.pos.x, item.pos.y)
    # When you have 300+ gold move to the red mark:
    if "gold-coin" > 300:
        hero.moveXY(50, 34)
    pass
1 Like

Howdy and welcome to the forum! We need you to post your code properly formatted. Please have a look at this topic, the edit your original post accordingly.
[Essentials] How To Post/Format Your Code Correctly

1 Like

got it, thank you for letting me know

1 Like

Perfect…and you’re welcome :slight_smile:

So, the mimic attracts treasure like a magnet. Send him around the square, in the center of the rows of coins. (If this is what you’ve done, good!)

Have your hero concentrate only on the enemies…the pet will gather all of the treasure.

1 Like

Oh, I just noticed…

if "gold-coin" > 300:

Is not correct. You should be testing hero.gold instead.

1 Like

worked perfect. thanks for your help.

As a note - where is the function hero.gold even mentioned so I can find this information myself in the future?

2 Likes

Good! That’s a tough question tho! I’ll have to root around to see if I can find the level…that, or some one who been there more recently than I can chime in.

2 Likes

I think I found out info on the correct wording for some things by clicking on individual methods. Eg:

image

5 Likes

awesome. thanks so much.

1 Like