[SOLVED] (Help) Thunderhooves

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 y
            hero.buildXY("fence", 18, 0)
        # else: 
        else:
            hero.buildXY("fence", P, 36)
    else:
        # moveXY right 10m towards the oasis.
        P = hero.pos.x + 10
        hero.moveXY(P, 30)
        pass

I have tried many things but, nothing is working. Help!!!

`hero.buildXY(“fence”, 18, 0)

You should not do that because the hero will just put the fence at 18,0. instead, put hero.buildXY("fence", yak.pos.x, yak.pos.y - 10) so that you build the fence at the yak


I still die.

What’s your code? I need to know

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 y
            hero.buildXY("fence", yak.pos.x, yak.pos.y - 10)
        # else: 
        else:
            hero.buildXY("fence", yak.pos.x, yak.pos.y - 10)
    else:
        # moveXY right 10m towards the oasis.
        P = hero.pos.x + 10
        hero.moveXY(P, 30)
        pass

Here.

else:
hero.buildXY(“fence”, yak.pos.x, yak.pos.y - 10)

on the second one use + 10

2 Likes

It worked! Thank you

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