Drop The Flag Help!


#1

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!

loop:
    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)
        self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            pos = item.pos
            itemX = pos.x
            itemY = pos.y
            self.moveXY(itemX, itemY)

Drop The Flag Level Help
#2

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).


#3

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.


#4

Hmm, not sure what the problem is. What browser is it? Does it work on http://direct.codecombat.com?


#5

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


#6

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.


#7

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


#8

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


#9

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 "


#10

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


#11

I believe 8, but let me double check.


#12

Yep, it is 8.0 safari.


#13

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


#14

IGNORE THIS TOPIC PLEASE, I HAVE FOUND IT OUT! I PULLED A IDIOT MISAKE AND FORGOT TO EQUIP HAMMER (lol)


#15

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


#16

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.


#17
  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)
  else:
      item = self.findNearestItem()
      if item:
          itemPos = item.pos
          itemX = itemPos.x
          itemY = itemPos.y
          self.moveXY(itemX, itemY)```

#18

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


#19

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.
```
code
```
comes out

    code

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


#20

My hero keeps on dieing from his own fire