Those of you guys who need more info and questions about the referee feel free to ask here! But before you do that, please review this topic before asking questions. And if the system is broken, it is recommended to contact the staff, as they know more about handling system issues about referees. Enjoy!

Can someone teach me how to use for loops in coffee script? Because whenever I try to do a for loop in coffee script it says â€śUnhandled Error: Type Error: Cannot read property â€ślengthâ€ť of undefinedâ€ť when I try to run the following referee code:

``````{
setUpLevel: ->
@wizard = @world.getThangByID("Wizard")
@hero.maxSpeed = 100
summonMeteorShower: ->
@XList = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
@YList = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
@radiusList = [5, 6, 7, 8, 9, 10]
@world.rand.shuffle(@XList)
@world.rand.shuffle(@Ylist)
@Iterate = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
targetx = @XList[0]
targety = @Ylist[0]
for x in @Iterate
for y in @Iterate
posx = 4*x
posy = 4*y
if ((posx-targetx)^2 + (posy-targety)^2) > (radius)^2
b = @instabuild("boulder", posx, posy)
b.pos.z = 100
b.velocity.z = -50
b.keepTrackedProperty("pos")
b.keepTrackedProperty("velocity")
b.shooter = @wizard
b.launchType = "attack"
onFirstFrame: ->
@Cooldown5 = 0
@Cooldown4 = 1
@Cooldown3 = 2
@Cooldown2 = 3
@Cooldown1 = 4
@Launch = 5
chooseAction: ->
if @world.age > @Cooldown5
@wizard.say(@icontext.five)
@Cooldown5 += 7
if @world.age > @Cooldown4
@wizard.say(@icontext.four)
@Cooldown4 += 7
if @world.age > @Cooldown3
@wizard.say(@icontext.three)
@Cooldown3 += 7
if @world.age > @Cooldown2
@wizard.say(@icontext.two)
@Cooldown2 += 7
if @world.age > @Cooldown1
@wizard.say(@icontext.one)
@Cooldown1 += 7
if @world.age > @Launch
@wizard.say(@icontext.launch)
@summonMeteorShower()
@Launch += 7
}
``````

Ohâ€¦Myâ€¦Gosh, that looks extremely confusing. Iâ€™m afraid I canâ€™t help, at all.

`@world.rand.shuffle(@Ylist)`
Here is your problem. `@Ylist` is `undefined` because the right name is `@YList`

@Bryukh yeah thatâ€™s definitely a problem. However, it seems like itâ€™s not my only problem it still doesnâ€™t workâ€¦
Hereâ€™s my code now: (itâ€™s under a tab so my posts arenâ€™t too long

My Code
``````{
setUpLevel: ->
@wizard = @world.getThangByID("Wizard")
@hero.maxSpeed = 100
summonMeteorShower: ->
@XList = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
@YList = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
@radiusList = [5, 6, 7, 8, 9, 10]
@world.rand.shuffle(@XList)
@world.rand.shuffle(@YList)
@Iterate = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
targetx = @XList[0]
targety = @YList[0]
for x in @Iterate
for y in @Iterate
posx = 4*x
posy = 4*y
if ((posx-targetx)^2 + (posy-targety)^2) > (radius)^2
b = @instabuild("boulder", posx, posy)
b.pos.z = 100
b.velocity.z = -50
b.keepTrackedProperty("pos")
b.keepTrackedProperty("velocity")
b.shooter = @wizard
b.launchType = "attack"
onFirstFrame: ->
@Cooldown5 = 0
@Cooldown4 = 1
@Cooldown3 = 2
@Cooldown2 = 3
@Cooldown1 = 4
@Launch = 5
chooseAction: ->
if @world.age > @Cooldown5
@wizard.say(@icontext.five)
@Cooldown5 += 7
if @world.age > @Cooldown4
@wizard.say(@icontext.four)
@Cooldown4 += 7
if @world.age > @Cooldown3
@wizard.say(@icontext.three)
@Cooldown3 += 7
if @world.age > @Cooldown2
@wizard.say(@icontext.two)
@Cooldown2 += 7
if @world.age > @Cooldown1
@wizard.say(@icontext.one)
@Cooldown1 += 7
if @world.age > @Launch
@wizard.say(@icontext.launch)
@summonMeteorShower()
@Launch += 7
}
``````

The code isnâ€™t enough to answer your question. What do you mean â€śdoesnâ€™t workâ€ť? Some error or something else?

Unable to load levelâ€¦ I donâ€™t know what doesnâ€™t work.

Edit: Nevermind. I opened the developer console and it says @instabuild needs object, but got string instead, then I realized I need to have boulder in my buildables, so I added that and the level finally loaded

The problem is: Thereâ€™s suppose to be a â€śsafety circleâ€ť. The boulders are supposed to fall everywhere except for within the safety circle.

``````for x in @Iterate
for y in @Iterate
posx = 4*x
posy = 4*y
if ((posx-targetx)^2 + (posy-targety)^2) > (radius)^2
b = @instabuild("boulder", posx, posy)
b.pos.z = 100
b.velocity.z = -50
b.keepTrackedProperty("pos")
b.keepTrackedProperty("velocity")
b.shooter = @wizard
b.launchType = "attack"
``````

This part of the code controls the launching of the boulders.

Isnâ€™t `if ((posx-targetx)^2 + (posy-targety)^2) > (radius)^2` supposed to make boulders only spawn outside of the circle?

Also, the boulders do no damage for some reason. The wizard has infinite attack damage. Itâ€™s supposed to kill the heroâ€¦

The boulder doesnâ€™t have any, the wizard does because the boulder is completely different and doesnâ€™t have any connection with the wizard since the game itself is shooting them

@Chaboi_3000 but I said b.shooter = @wizard

But you didnâ€™t say what it does when it touches a target

The wizardâ€™s attack damage is 9001. I said b.launchtype = â€śattackâ€ť. Shouldnâ€™t that define what happens when it hits a target?

Try asking @Bryukh, heâ€™s better at this than me.

Bryukh is currently offline, it seems likeâ€¦

Yeah, itâ€™s 1:41 AM at his timezone

Oh I just noticed the huge time gap between the posts

Try to check the referee in the level `blind-distance`. Or save your level and let me check it. There could be several possible issues, Itâ€™s hard to say without additional info.

1 Like

Boulders arenâ€™t missiles so they donâ€™t use their shooter attackDamage. Add `Shell` component to the boulder template.

1 Like

@Bryukh okay Iâ€™ve saved the level. I added the thangTemplate: â€śShellâ€ť to the boulder in the existence.Builds part of the referee. Iâ€™m not sure if thatâ€™s what you meant by adding the Shell component to the boulder templateâ€¦

Anyway, it seems like the boulders still arenâ€™t doing any damageâ€¦ You can take a look and see if anythingâ€™s wrong via the link: https://codecombat.com/editor/level/meteor-strike

If you are using a template for `buildables` then you need a thang which will be a template. Iâ€™ve added `Boulder` and set `friendlyFire` true for this. Check version history for my last changes.