Though I have managed to finish Thunderhooves quest in the desert, I thought i would try to tidy up the code a bit, just cause. However, when I try to do the following
while True:
yak = hero.findNearestEnemy()
yakPosX = yak.pos.x
yakPosY = yak.pos.y
heroPosX = hero.pos.x
heroPosY = hero.pos.y
if yak:
# If yak.pos.y is greater than hero.pos.y
if yakPosY > heroPosY:
# buildXY a "fence" 10m below the yak.
hero.buildXY("fence", yakPosY, yakPosY - 10)
else:
# buildXY a "fence" 10m above the yak.
hero.buildXY("fence", yakPosX, yakPosY + 10)
else:
# moveXY right 10m towards the oasis.
hero.moveXY(heroPosX + 10, heroPosY)
I get an error at line three, telling me to use hero.pos instead. I don’t follow. Why can’t I store enemy.pos.x in to a variable called enemyPosX…or any variable for that matter. Is it due to item restrictions? Or am I missing something here?
Thanks in advance.