# [SOLVED] SarvenSum - defeat ogres

Hy guys, i’ve another problem whit new level…

I complete the level but dont defeat the ogres becous hero move to x red …
there is a time metod? like to
if enemy <0:
hero.wait(30sec)
There is my code:

``````def scappa():
enemy = hero.findNearestEnemy()
if enemy and enemy.health > 0:
hero.attack(enemy)

else:
hero.moveXY(redX.x, redX.y)

whiteX = {'x':27, 'y':42}
redX = {'x':151 , 'y': 118}
hazards = hero.findHazards()
hero.moveXY(whiteX.x, whiteX.y)
max = 0
min = 999
index= 0
while index < len (hazards):
item = hazards[index]
if item.value > max:
max= item.value
if item.value < min:
min = item.value
index +=1

hero.say(max+min)
scappa()
``````

O_o … i’ve solved, but i dont understand…
only change this line in function:

``````# from
else:
hero.moveXY(redX.x, redX.y)
# to
else:
hero.move(redX)
``````

now works fine, but i don’t understand why it work?

Try asking @Luke10, he was the one who changed it to solved.
Edit: I’ve removed the [SOLVED] Tag.

See The new boots and move vs moveXY for explanation of your question. Replace loop: with while True: and self with hero in the old post.
So while using moveXY(x, y) you block all other actions and using move(position) you are much more flexible. Because move(position) works only within a loop the changes in your code will be:

``````def scappa():
# code...
hero.move(redX)
# code...
while True:
scappa()
``````

why is the function called scappa?

Because i’m a italian

Thanks xython for explanation

Yeah I changed it because of this:

He stated that he solved the issue so I changed it…

Also in the edits he changed what you put back to what I put:
It went from this:

to this: