Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Underground Business: I need help please


Can you help me please because I don’t know how to get the pet move to my flag and here is my code

# Accumulate 300 gold and escape from the dungeon.

def onSpawn(event):
    # Send the pet to walk around the dungeon:
    flag = hero.findFlag("green")
    flag = pet.findNearestByType("green")
    if flag:
        pet.moveXY(flag.pos.x, flag.pos.y)

pet.on("spawn", onSpawn)
while True:
    # When you have 300+ gold move to the red mark:
    if == 300:
        hero.moveXY(50, 34)

flag = pet.findNearestByType("green")

The type is “flag”.

You should use loop inside onSpawn or it will be one time event.


If that is a little confusing what @htrnblr is trying to say is that in findNearestByType, there is no object called green. But you can find the nearest flag by type by inserting “flag” inside the brackets.


Thank guy.:slightly_smiling_face: