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ā€¦