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

The Trials (Sarven desert one)

while True:
    enemy = hero.findNearestEnemy()
    flag = hero.findFlag()
    item = hero.findNearestItem()
    #this will follow the flag
    if flag:
        hero.moveXY(flag.pos.x, flag.pos.y)
    #this will find and attack an enemy
    if enemy:
    #this will find and pickup item
    item = hero.findNearestItem()
    if item == "mushroom":
1 Like

i got this issue with my code. although technically it works i get a problem collecting the mushrooms.
having the code structured like this, the hero ping-pongs between killing an enemy and picking up a mushroom.

Thanks in advance for any tips.

1 Like

My tip for you is to turn this:

into this so the flag is prioritized.

elif enemy:

I recommend removing the if item part because you can use flags to handle the mushroom collecting.


thanks for the reply, will do that