I’m stuck on this level, i have a problem on line 10
the language is Python
here is the code:
Move right, to the oasis.
Build a “fence” above or below when you see a yak.
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.
hero.buildXY(‘fence’, hero.pos.x, yak.pos.y - 10)
# else:
else:
# buildXY a "fence" 10m above the yak.
hero.buildXY('fence', hero.pos.x, yak.pos.y + 10)
pass
else:
# moveXY right 10m towards the oasis.
hero.moveXY(hero.pos.x + 10, hero.pos.y)
pass
I tried another time but i have the same problem
Try again, with a sword, you have no chance of building anything
Well, @qwerty is right. Equip a hammer.
Also, you want to do yak.pos.x instead of hero.pos.x
while True:
yak = hero.findNearestEnemy()
if yak:
if yak.pos.y > hero.pos.y:
hero.buildXY('fence', yak.pos.x, yak.pos.y) # Use yak's position
else:
# Vice Versa, do the same but opposite
else:
hero.moveXY(hero.pos.x + 10, hero.pos.y)
You have, he just don’t have a hammer
I said “with a sword” -_-
I mean you need a hammer to somplete this level
Thanks, now it works. I was using a wrong hammer, now with the hammer (20) is work, it was my mistake.
now it works thx. It was my mistake