(solved) Underground business i need help


#1

i need help with underground business. here is my code:

i can’t figure out what’s wrong.


#2

You do not need to put pet.on("spawn", onSpawn) in a while-true loop. It automatically loops itself.


#3

okay but now it has two errors:


#4

What is gold? Try using hero.gold. Also be sure to use >= because there could be more than 300 gold (>= means greater than or equal to), or else you will be assigning 300 to the variable gold.
I don’t quite understand the enemy issue, but unless you don’t have any glasses equipped, it should be working.

Also a little side note: I suppose that you should let the pet move to each corner of the dungeon because it is magnetic and attracts items, and there is more than one type of item to collect.


#5

thanks! it worked! (it has to be 20 characters)


#6

I can’t get 300 coins, only 150 coin. Do anyone know the resolution?

Accumulate 300 gold and escape from the dungeon.

def onSpawn(event):
while True:
# Send the pet to walk around the dungeon:
pet.moveXY(19,35)
pet.moveXY(20,37)
pet.moveXY(21,32)
# 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


#7

Did you get all the gold from the mimic, or did you not get any at all.


#8

I only get 150 gold and don’t have any way to get all 300 gold. I don’t know why.


#9

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:


#10

for one you shouldn’t put it in a while loop.


#11

I have passed. Thank you all :)))