[UnderGround Business] Can't collect 300 coin. (Only 150)


I don’t know why i can’t collect enough 300 coins, please help me to resolve it?

Accumulate 300 gold and escape from the dungeon.

def onSpawn(event):
    goldCoin = pet.findNearestByType("coin")
    if goldCoin:
    # Send the pet to walk around the dungeon:
        pet.moveXY(goldCoin.pos.x, goldCoin.pos.y)
    # Don't forget to return it to the hero:
        pet.moveXY(hero.pos.x, hero.pos.y)
    pass
pet.on("spawn", onSpawn)

while True:
    # Guard peasants:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    # When you have 300+ gold move to the red mark:
    if hero.gold >=300:
        hero.moveXY(50, 34)
    pass

Please format your code according to the FAQ.

Please, read that instruction again.

Your code makes the pet find the nearest coin, go there and return. It’s all.

I have changed my code but it still return back 150 coin :frowning:#
Accumulate 300 gold and escape from the dungeon.

def onSpawn(event):
    pet.moveXY(32, 56)
    pet.moveXY(63, 55)
    pet.moveXY(73, 14)
    pet.moveXY(43, 7)
    pet.moveXY(25,8)
    # Don't forget to return it to the hero:
    pet.moveXY(hero.pos.x, hero.pos.y)
   
    # Guard peasants:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    # When you have 300+ gold move to the red mark:
    if hero.gold >=300:
        hero.moveXY(50, 35)
    pass

the coins are being dragged BEHIND the pet
even if the pet moves to your position, not all the coins get collected.
also, u know the peasants mine 5 coins per second, so you can wait for 30 seconds and get the other 150 coins
#1 rule about being a coder:
be creative :wink:

I don’t understand what are you talking? Please explain a little?

The coins are attracted my the mimic like a magnet, but it won’t perfectly stick on to it.

so how you did before?

You should try looking at your mimic move around the dungeon because you have to aim so it walks near the coins.
Did you try @Bryukh’s hint?

Looks like you lost “while true” part. Also don’t forget to assign an event handler.

1 Like

Even if i let mimic run around, it is still 150 coin :frowning:
Anyone who can give me the correct code? Don’t instruction :frowning:

I have done. Thank you all

Good job @le_thi_ngoc_le