i need help with underground business. here is my code:
i can’t figure out what’s wrong.
You do not need to put
pet.on("spawn", onSpawn) in a while-true loop. It automatically loops itself.
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
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.
thanks! it worked! (it has to be 20 characters)
I can’t get 300 coins, only 150 coin. Do anyone know the resolution?
# Send the pet to walk around the dungeon:
# Don’t forget to return it to the hero:
# Guard peasants:
enemy = hero.findNearestEnemy()
# When you have 300+ gold move to the red mark:
if hero.gold >=300:
Did you get all the gold from the mimic, or did you not get any at all.
I only get 150 gold and don’t have any way to get all 300 gold. I don’t know why.
Even if i let mimic run around, it is still 150 coin
Anyone who can give me the correct code? Don’t instruction
for one you shouldn’t put it in a while loop.
I have passed. Thank you all :)))
This level is weird. Why does this code not work:
def onSpawn(event): item = pet.findNearestByType("coin") if item: pet.moveXY(item.pos.x, item.pos.y) pet.moveXY(hero.pos.x, hero.pos.y)
This code makes the Mimic walk to the closed copper coins and go back to the hero only once. After that, it just stands there.
This is the solution suggested in the hints section, but it doesn’t work.
I was thinking “duh, it needs to be looped”, but a) putting this in a while-True loop results in only one repetition (see below) and b) @Hellenar claimed:
But, why would it loop automatically?
And if it does/should, why doesn’t the mimic repeat its action?
When the Mimic goes to the copper coins and then returns to the hero, the coins aren’t dragged along with it all the way - for some reason it leaves them behind after a few meters:
For the record, I have solved this level by just sending the Mimic in a circle using absolute coordinates.
My goal here is to understand A) why the other solution doesn’t work, and B) if it doesn’t work, why is it (misleadingly) shown in the hints section?
Upon spawning, the pet automatically runs the function
onSpawn. (not sure if this explanation will suffice)
I’m afraid not. When the pet spawns, the function is executed once (also, spawn happens only once). There is no command that would explicitly make it loop, is there?
.on event handler is a loop in and of itself - is it?
You only need to tell the pet to go around the dungeon. then make it come back.
Did you read this part that I wrote?
The code does not work because the mimic cannot see the other items. It cannot see through walls either.