[SOLVED] Mind the trap --- help please

2 Likes

Can you post all your code using this button: image
Thanks!
Lydia

3 Likes
while True:
    flag = hero.findFlag()
    enemy = hero.findNearestEnemy()
    
    if flag:
        # Pick up the flag.
        hero.pickUpFlag(flag)
        hero.say("I should pick up the flag.")
    elif enemy:
        # Only attack if the enemy distance is < 10 meters
        if self.distanceTo(enemy) < 10:
            hero.attack(enemy)
1 Like

What’s your problem?
P.S. Why do you use self, if most of code is written with hero?

2 Likes

I see no problem with your code. You just have to submit and use flags to move around.
Lydia
P.S. PeterPalov, I have been experiencing some levels where I type in ex. attack, and it autofills for me, but fills to self. I think it is a glitch.

3 Likes

I saw self only in haste. Let’s think it’s a glitch.

2 Likes

thanks everyone. i had trouble moving the flag… it was hard to survive if you didnt time it correctly!

2 Likes

Yes, sometimes using flags is difficult.
Congrats on solving the level!

2 Likes

Congrats on solving the level!
Lydia

2 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.