i'm learning lua by playing codecombat.com and i'm having trouble with this 1 level... here is the script, the error i'm getting is end expected?
Best Answer JohanLiebert , 29 July 2015 - 04:35
Firstly you should be indenting Secondly, you have two "else" statements for one "if" statement, you can't do that :P Thirdly, you have one too many "end" statements loop local enemy = self:findNearestEnemy() local distance = self:distanceTo(enemy) if distance < 5 then self:attack(enemy) else self:shield() --else [YOU CAN'T HAVE TWO ELSE'S] self:moveXY(41, 34) end --end [TOO MANY END STATEMENTS] endGo to the full post »
i'm learning lua by playing codecombat.com and i'm having trouble with this 1 level... here is the script, the error i'm getting is end expected?
whats the level name?
whats the level name?
stillness in motion.
Why there are 3 ends? Only one is needed, unless you didn't post whole code
you can't have 2 elses with one if xD
if condition then
code...
elseif condition2
other code...
else
last case
end
Why there are 3 ends? Only one is needed, unless you didn't post whole code
you can't have 2 elses with one if xD
if statement then
code...
elseif statement2
other code...
else
last case
end
i needed the 2 else's but i figured it out >.< i just went with a more simple script i guess i was over thinking it. lol
Firstly you should be indenting Secondly, you have two "else" statements for one "if" statement, you can't do that :P Thirdly, you have one too many "end" statements loop local enemy = self:findNearestEnemy() local distance = self:distanceTo(enemy) if distance < 5 then self:attack(enemy) else self:shield() --else [YOU CAN'T HAVE TWO ELSE'S] self:moveXY(41, 34) end --end [TOO MANY END STATEMENTS] end
0 members, 1 guests, 0 anonymous users