And what is your code? I can not guess your code. Blowing up yourself usually happens by standing to long on the fire-trap, so it arms itself and immediately blows up because you trigger it (or was it because you move off it and then on it again? I can’t recall and I don’t want to fire up a level just to test).
With your code and the described problems you have I could possibly solve it…
Alright but I forgot how to type my code is it with the tick marks to show indents like this.
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.)
````````self.buildXY("fire-trap", 30, 45)
````````self.buildXY("fire-trap", 30, 31)
````````self.buildXY("fire-trap", 30, 16)
````else:
````````item = self.findNearestItem()
````````if flag:
````````````itemPos = item.pos
````````````itemX = itemPos.x
````````````itemY = itemPos.y
````````````self.moveXY(itemX, itemY)
all by themselves
```
code
```
well it says i have no code problems or any wrong indents its just when i submit he just keeps repeatedly building fire traps and blowing himself up
Merged Doublepost
can you help me with that code that i posted above
I fixed the code (added the ```s) . . . now we can look at it and help. (looks ugly with all those ` in it but I’m not taking them out. putting in the correct ``` was more than I felt I really should do…)
And you have never made the changes I said to do in the other thread post. (speaking of other thread one of them is gonna die. OK, closed the other one.)
I copied my help (that you ignored) from the other thread.
------------------------------------------------------------------------
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)
My code is not working, someone help pls
loop:
flag = self.findFlag()
if flag:
self.buildXY("fire-trap", 30, 45)
self.buildXY("fire-trap", 30, 31)
self.buildXY("fire-trap", 30, 16)
else:
item = self.findNearest(self.findItems())
if flag:
itemPos = item.pos
itemX = itemPos.x
itemY = itemPos.y
self.moveXY(itemX, itemY)
if item:
self.findNearest(item)
The reply just before your reply clearly tells you how to present your code properly, please do so!
Also, as @Vlevo likes to state it: “Help us help you.” (I think he stole that from me…)
While I’m usually happy to help, I have little interest to figure what exactly is wrong with your code, so please tell me what’s not working.
You have multiple conditions which are mutually exclusive (if flag: <-> else if flag:
), you have function calls where you don’t use the result (self.findNearest(item)
) or which are plain invalid (self.findNearest(item)
).
Please go step by step through your code and read out loud each step in natural language.
First step: Find a flag on the field and assign the flag-object to the variable flag.
Second step: If there is a flag, build firetraps at (30, 45), (30, 31) ...
Already the second step looks a bit strange, as these positions are not exactly close to each other and you rarely have to build firetraps all over the place without being specifically told so.
k noted, thx for the info
please help me I have read all of the replys but still cant beat it
Is the problem your code?
…that you don’t understand the directions?
…or ??
my code i cant beat the level with any of my codes
Well, show us your code so we can see if there is anything wrong with it.
flag = self.findFlag()
if flag:
self.buildXY("fire-trap", 30, 45)
self.buildXY("fire-trap", 30, 31)
self.buildXY("fire-trap", 30, 16)
else:
item = self.findNearest(self.findItems())
if flag:
itemPos = item.pos
itemX = itemPos.x
itemY = itemPos.y
self.moveXY(itemX, itemY)
if item:
self.findNearest(item)
Merged Doublepost
nick please help me beat the level
Your code runs only once. In the very first gametick you search for a flag (obviously in the first one it doesn’t exist) and then you search for an item.
Your condition is also a bit mixed up.
If there is a flag
Do something
Else (if there is no flag)
Find the nearest item
If there is a flag
Move to the item
If there is an item
find the nearest item and do nothing with it
If there is no flag, there obviously can’t be a flag in the next line. Also the very last condition makes no sense (see in the textbox why that is).
To make it short, please read all of the replys again. A lot of the mentioned problems are already discussed.
EDIT Your code is identical to
http://discourse.codecombat.com/t/drop-the-flag-level-help/1567/72?u=j_f_b_m
You can’t have read all replies, as I answered already what is wrong with it.
I know this is late, but the code has to be (“fire-trap”) not (“fire trap”)
Hi Nick me and my friend have been on this level for ages just wondering if i could get a private message if its ok ? Thank You.
Please ive been trying for 3 weeks
And yet we haven’t heard hide nor hair of your problem…
Read the above posts. See if your problem is up there already…
and/or Post what is happening, what is not happening, and your code and we are happy to look at it and help you get it working. Read the FAQ and properly post your code so that it formats correctly.
I’m also stuck on this level. Got the code to win for me? Please. I use Python.