Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[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:
There is my code:

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

        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


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

# from
        hero.moveXY(redX.x, redX.y)
# to

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

Try asking @Luke10, he was the one who changed it to solved. :man_shrugging:
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...   
# code...
while True:

why is the function called scappa?

Because i’m a italian :slight_smile:

Thanks xython for explanation :slight_smile:

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: