Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Drop The Flag Help!


Ok so i’ve been playing code combat and i’ve been stuck on this level for a while now. May I have some help please?

This is what i have so far!

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

    flag = self.findFlag()
    if flag:
        # How do we get fx and fy from the flag's pos?
        flagpos = flag.pos
        fx = flag.pos.x
        fy = flag.pos.y
        self.buildXY("fire-trap", fx, fy)
        item = self.findNearestItem()
        if item:
            pos = item.pos
            itemX = pos.x
            itemY = pos.y
            self.moveXY(itemX, itemY)

Drop The Flag Level Help

That looks good–now you have to hit submit and place flags where the ogres are going to come out. (The flags only show up when you hit submit).


Weird, because when I press submit and place a flag my character just freezes in place, does nothing and doesn’t collect coins at all. Also, after the submit play time is over i get a notification (In game) saying

" Line 11 : undefined is not a function (evaluating ‘tmp1temp22, _aether.restoreAPIClone(_aether, tmp24), _aether.restoreAPIClone(_aether, tmp25))’) "

This appears in the Red Box that says something is wrong with your code, it is also flashing the self.buildXY(“fire-trap”, fx, fy) code line.


Hmm, not sure what the problem is. What browser is it? Does it work on


Sorry for late response, was at school, but i tried on Safari newest version. I’ll try on firefox.


Ok, so i tried on firefox, says "Uh oh! your browser is to old to run this software."
I’ve tried all my computers and it does the same thing every time. only browser that i have that works for code combat is Safari on my Mac Book Pro.


The problem is the location should be iitemx = item.pos.x and itemy = itemy.pos.y


trying it now. but just restating the problem is that the flags arn’t moving my character. Still will trying though.


Didn’t do anything, tbh it just changed the name of the item. The original was fine i’m just getting a error when i place the flag it just freezes my character and gives me a error message "


The Safari version you are talking about, is version 8, or 7.1, or 6.2…?


I believe 8, but let me double check.


Yep, it is 8.0 safari.


Hmm, I still can’t reproduce the bug even with the same browser and code. Were you able to place flags successfully in Coinucopia?




You are not alone, I have made similar mistakes more than once. :smile:


That’s what i did. you did it same as me and i won. just place the flag where you want to put the fire trap, and it builds it.

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


need help thats my code that doesn’t work like all the other codes i right :disappointed:


Well, for starters you did not do what the instructions told you…
"(Look below at how to get x and y from items.)"

“Seconders”, you are building 3 firetraps for every flag placed.

Change the code so that you build the fire-trap where the flag is, using the template for “item” (iow: try copying the item code and replacing “item” with “flag”…)

and for “thirders” (snicker at self) learn how to use ``` to format your code so we can see if your indenting is correct.
comes out


(and yes I put four spaces in front of both "code"s)


My hero keeps on dieing from his own fire