In that level you should move standing guard in the middle of the village, until you see an enemy (which approach from left or right), at which time you will go and attack the enemy, and then return to the middle.
loop:
enemy = self.findNearestEnemy()
if enemy:
# Either attack the enemy...
self.attack(enemy)
else:
# ... or move back to your defensive position.
self.moveXY(xx, yy)
Replace xx and yy with your x and y values that you want to return to.
It looks like your code is written in the Lua programming language (or something else other than Python).
Make a backup of your code and save it in a text editor, then press the “Reload” button in the top-right of the game interface—this will reset your code to the starting code for your current programming language. Then you can adapt your solution to Python.
In case anyone is new trying this… The main issue is that the level loads with the first enemy variable not being local in the lua game at least. So it was making everything break. Once I made the enemy local it worked as it should have.
Thank you! I’m new to coding just been messing around with it the past week or so… so this one threw me through a loop (pun intended) for a long time …
As said to you in the another topic: We don’t give out solutions! It’s our number 1 rule.
Post code that you have written, tell us your problem and we’ll help you.
Post it formatted: [Essentials] How To Post/Format Your Code Correctly.
If you don’t do that then no-one will help you and we’ll just shut the topic.
Danny