Flags are no longer safe!

why can`t I use flags in any level???
I found this glich in apcolipse world 2
and also I useley chaet with yetis,robombs,skeleins and burl

My code is here:
while True:
flag = hero.findFlag()
if (flag):
if hero.distanceTo(flag) > 10 and hero.isReady(‘jump’):
hero.jumpTo(flag.pos)
else:
hero.pickUpFlag(flag)

my hero is not reacting

@Daniel_Stotskyy please format your code correctly using the </> button when writing your post. Then we can help you.
Thanks!

while True:
    flag = hero.findFlag()
    if (flag):
        if hero.distanceTo(flag) > 10 and hero.isReady('jump'):
            hero.jumpTo(flag.pos)
        else:
            hero.pickUpFlag(flag)
    

I honestly have no idea if this will help, but try taking the parentheses off (the ones surrounding “flag” after the “if”) does that make any sense?

Yes, as @enPointe77 said in Python you don’t use parentheses in an if statement.

Are you sure?!

if ( 5 > 3):
    print ("5 > 3")

console:
изображение
I cannot help you more, never used flags, finished Apocalypse without flags when i had two years CoCo experience…

I’m quite sure this won’t work, jumpTo method requires smth like ({“x”: flag.pos.x, “y”: flag.pos.y}) as far as I remember.

1 Like

Passed codecombat.com/play/level/rich-forager? with

while True:
    flag = hero.findFlag()
    if (flag):
        if hero.distanceTo(flag) > 10 and hero.isReady("jump"):
            hero.jumpTo(flag.pos)
        else:
            hero.pickUpFlag(flag)

I think the code is OK

Yep, I was wrong, flag.pos works for jumping. And the code is ok.

1 Like

maybe a flag bug.

man, I was thinking only JS does if with parentheses…