[SOLVED] Drop The Flag Level Help in Backwoods Forest

Okay, this helped a lot.

Thank you!!

The code is self.(I HATE CODE)

yes please.
sorry i have been playing code combat for a while and stopped for a while when I got to this level.
then i came back to see if there was something i missed, until i found this email and thought id ask you for some help. my code is starting to confuse me and I wanted to get some guidance from you on this topic.

cuold you give me one too?

What does your code look like? Maybe try pasting it here in the thread for people to look at :slight_smile:

nick, can you help? my code like this,but i cannot pass the level

loop:
    flag = self.findFlag()
    if flag:
        # How do we get fx and fy from the flag's pos?
        # (Look below at how to get x and y from items.)
        flagPos = flag.pos
        fx = flagPos.x
        fy = flagPos.y
        self.buildXY("fence", fx, fy)
        self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            self.moveXY(itemX, itemY)
    

the result is like this ,i already collect all the coins,but i cannot pass the level?

You’re not creating fire-trap objects, you’re creating fences. The Ogres aren’t defeated, they’re just blocked.

Change self.buildXY(“fence”, fx, fy) to self.buildXY(“fire-trap”, fx, fy) and watch the fireworks. :smile:

thank you, i get it.

ok cool. i will hold on let me log into code combat

loop:
    flag = self.findFlag()
    if flag:
        # How do we get fx and fy from the flag's pos?
        # (Look below at how to get x and y from items.)
        
        var fx= 
            
        self.buildXY("fire-trap", fx, fy)
        self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            self.moveXY(itemX, itemY)
  • > List item

ok i have been working and my code still doesnt work

loop:
    flag = self.findFlag()
    if flag:
        flagPos = flag.pos
        fx = flagPos.x
        fy = flagPos.y
        self.buildXY("fire trap", fx, fy)
        self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            self.moveXY(itemX, itemY)

explain what is “not working” …details.

figured it out. it was probobly a glitch

can you help me with with rich forager

I did what you said how ever my character does what i need him to do but after placing the trap and picking up the flag he poops out a random trap somewhere

Can i see your code? I still can’t figure mine out:(

which level are you on?

loop:
    flag = self.findFlag()
    if flag:
            flagPos = flag.pos
            flagX = flagPos.x
            flagY = flagPos.y
            self.buildXY("fire-trap", flagX, flagY)
            self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            self.moveXY(itemX, itemY)

XD Omg, thanks so much!

I need some help with this also