[SOLVED]Underground Business

My hero just does not have enough health here is my code:

Accumulate 300 gold and escape from the dungeon.

def onSpawn(event):
# Send the pet to walk around the dungeon:
pet.moveXY(26, 55)
pet.moveXY(71, 57)
pet.moveXY(71, 11)
pet.moveXY(20, 11)
pet.moveXY(21, 36)
pet.moveXY(15, 36)
pet.moveXY(hero.pos.x, hero.pos.y)
# Don’t forget to return it to the hero:

pass

pet.on(“spawn”, onSpawn)

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

uhh you didnt format it correctly

how do I do that?

I am new to this.

Accumulate 300 gold and escape from the dungeon.
def onSpawn(event):
    # Send the pet to walk around the dungeon:
    pet.moveXY(26, 55)
    pet.moveXY(71, 57)
    pet.moveXY(71, 11)
    pet.moveXY(20, 11)
    pet.moveXY(21, 36)
    pet.moveXY(15, 36)
    pet.moveXY(hero.pos.x, hero.pos.y)
# Don’t forget to return it to the hero:

pass
pet.on(“spawn”, onSpawn)

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

that is what your code should look like once formatted

but how do I make it look like that?

use the </> button

You can see how to formatt it here
Lydia

press the </> button and paste your code in the three backtics

And what level is this?
Lydia

It is in the desert Lydia

I tried that but it deleted my code.

https://codecombat.com/play/level/underground-business? this is the link


does it look like this

no :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull:

1 Like

Accumulate 300 gold and escape from the dungeon.

def onSpawn(event):
# Send the pet to walk around the dungeon:
pet.moveXY(26, 55)
pet.moveXY(71, 57)
pet.moveXY(71, 11)
pet.moveXY(20, 11)
pet.moveXY(21, 36)
pet.moveXY(15, 36)
pet.moveXY(hero.pos.x, hero.pos.y)
# Don’t forget to return it to the hero:

pass

pet.on(“spawn”, onSpawn)
while True:

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

hero.moveXY(50, 34)

okay try doing < 200 to get your hero to collect the stuff he did not

Try making him go to 69, 57 first then make him go to the hero then do the same thing for the other gold and stuff

my guy is just going to the x mark and attacking only 1 time.

Accumulate 300 gold and escape from the dungeon.
def onSpawn(event):
# Send the pet to walk around the dungeon:
pet.moveXY(26, 55)
pet.moveXY(71, 57)
pet.moveXY(71, 11)
pet.moveXY(20, 11)
pet.moveXY(21, 36)
pet.moveXY(15, 36)
pet.moveXY(hero.pos.x, hero.pos.y)
# Don’t forget to return it to the hero:

pass
pet.on(“spawn”, onSpawn)
while True:

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