A Mayhem of Munchkins


#1

loop
local enemy1 = self:findNearestEnemy
if enemy1 then
self:attack(enemy1)
self:attack(enemy1)
end

its not working please help :frowning:


#2

Please format your code with radiant, harmonious formatting as described in the FAQ. Also, phrases like “it’s not working.” and “please help” aren’t helpful. In future please describe what is or isn’t happening. For example, are there any error messages?

(Also, there are several languages available in CodeCombat, and it is often helpful to say what language you’re using.)

That said, I’ve encountered this particular problem before:

local enemy1 = self:findNearestEnemy

needs to read

local enemy1 = self:findNearestEnemy()

For some reason the Lua code for findNearestEnemy doesn’t have the brackets. I’ve updated it, but the change won’t take effect until one of the owners approves it.


#3

Deatrix the error messaage says "Found an expression but as expected: While
and there is not “While” wtf?


#4

I honestly don’t know why it gives that particular error (at least it’s consistent), but it will work if you add the brackets.


#5

Thanks it worked I had to tweak it because I accidentally had a space in a area