[SOLVED] I need help with drop the flag

while True:
    flag = hero.findFlag()
    if flag:
        # How do we get flagX and flagY from the flag's pos?
        # (Look below at how to get x and y from items.)
        
        
        hero.buildXY("fire-trap", flagX, flagY)
        hero.pickUpFlag(flag)
    else:
        item = hero.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            hero.moveXY(itemX, itemY)

Hi kayden, the problem with your code is that you never find the flag’s position. (flagX and flagY are never defined) If you want to do that, it would look something like this:

flagPos = flag.pos
        flagX = flagPos.x
        flagY = flagPos.y

Hope this helps!
Grzmot

this

is the problem you are suppose to do this

you basically copy all of this

and change item into flag

        if enemy:
            
            flagPos = flag.pos
            flagX = flagPos.x
            flagY = flagPos.y
        
        hero.buildXY("fire-trap", flagX, flagY)
        hero.pickUpFlag(flag
        

@Deadpool198 can you help me if you are on?

if enemy:
            
            flagPos = flag.pos
            flagX = flagPos.x
            flagY = flagPos.y
        
        hero.buildXY("fire-trap", flagX, flagY)
        hero.pickUpFlag(flag

change if enemy into if flag and add a ) hereimage

        flag.Pos = flag.pos
        flagX = flagPos.x
        flagY = flagPos.y
            
        hero.buildXY("fire-trap", flagX, flagY)
        hero.pickUpFlag(flag)

add a if flag at the top

That is the right code