Hello Guys,
i dont understand whats wrong with my code. The Soldiers are attacking the ogre but my hero is just running into the Rocks. Here´s my code:
ordersGiven = 0
while ordersGiven < 5:
hero.moveXY(hero.pos.x, hero.pos.y - 10)
hero.say(“Attack!”)
ordersGiven + 1
while True:
enemy = hero.findNearestEnemy()
if ordersGiven == 5:
hero.attack(enemy)
However I can’t tell if your indentation is correct - if you’re still having problems can you repost your code with it formatted according to the instructions here.
Here you are just getting the amount of ordersGiven plus one, and not doing anything with it. What you need to do is add and assign, or something more like this.
ordersGiven += 1
Here the plus adds one to the variable, and the equals assigns that new amount to the variable.