Drop the Flag Level Help[SOLVED]

Hi, I was working on my code and ran into a small problem.
Here is my code

# Put flags where you want to build traps.
# When you're not building traps, pick up coins!

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.)
        self.buildXY("fire-trap", 30, 45)
        self.buildXY("fire-trap", 30, 31)
        self.buildXY("fire-trap", 30, 16)
        hero.buildXY("fire-trap", flagX, flagY)
        item = hero.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            hero.moveXY(itemX, itemY)

Here is a screenshot

Replace that with:

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

This will define flagX and flagY as the flag’s x and y coordinates.

Thank you have a good day!

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