[SOLVED] Help on thunderhooves (python)

I need help on thunderhooves
Here is my code:
while True:
yak = hero.findNearestEnemy()
if yak:
# If yak.pos.y is greater than hero.pos.y
if yak.pos.y > hero.pos.y:

        # buildXY a "fence" 10m below the yak.
        O = yak.pos.y - 10
        hero.buildXY("fence", 18, O)
    # else: 
    else:
        
        # buildXY a "fence" 10m above the yak.
        S = yak.pos.y + 10
        hero.buildXY("fence", 36, S)
    pass
else:
    # moveXY right 10m towards the oasis.
    P = hero.pos.x + 10
    hero.moveXY(P, 30)
    pass

My hero gets to the oasis, but all the yaks are chasing her. I can’t get to the end because she dies.

Hi @LunaFromTheMoon and welcome to the forum! :partying_face:

Can you format your code as it is described here so we will be able to help you?

Andrei

while True:
    yak = hero.findNearestEnemy()
    if yak:
        # If yak.pos.y is greater than hero.pos.y
        if yak.pos.y > hero.pos.y:
            
            # buildXY a "fence" 10m below the yak.
            O = yak.pos.y - 10
            hero.buildXY("fence", 18, O)

MOD edit: code removed to prevent a solution being posted

1 Like

Instead of those numbers, try to use hero’s x coordonate.

Andrei

Thanks! Turns out I had the wrong builder’s hammer on.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.