如果,否则,如果和结束Lua
你知道Lua为什么会这样吗如果,否则,如果和结束Lua,lua,if-statement,Lua,If Statement,你知道Lua为什么会这样吗 if Pieza == 1 then if Rotacion == 1 then Piezas = Cuadrado1 else if Rotacion == 2 then Piezas = Cuadrado2 else if Rotacion == 3 then --this is Line 273
if Pieza == 1 then
if Rotacion == 1 then
Piezas = Cuadrado1
else if Rotacion == 2 then
Piezas = Cuadrado2
else if Rotacion == 3 then --this is Line 273
Piezas = Cuadrado3
else if Rotacion == 4 then
Piezas = Cuadrado4
else
io.write("Me Envio una rotacion que no existe? \n");
end
--this end closes the if inside the first if the one using to compare Rotacion
else if Pieza == 2 then
if Rotacion == 1 then
Piezas = I1
else if Rotacion == 2 then
Piezas = I2
else if Rotacion == 3 then
Piezas = I3
else if Rotacion == 4 then
Piezas = I4
else
io.write("Me Envio una rotacion que no existe? \n");
end
--this end closes the if inside the first if the one using to compare Rotacion
else --this else is in case Pieza != 1 || 2
io.write("Me Envio una pieza que no existe? \n");
end --this close the whole if (the one comparing "Pieza")
我得到的错误是这个“结束”预期(在第273行关闭“如果”)靠近“其他”
此外,在每个if之后添加end(这不是应该做的,但无论如何都要尝试)也不起作用
如果你需要我翻译成英语,我很乐意为你做评论和其他事情,但我认为这不是这个问题的必要条件。它是
elseif
,而不是else If
(注意空格)。错误是因为解释器希望每个else
块都有end
有关更多信息,请参阅。这是一个好问题。我第一次用Lua编程时也遇到了同样的问题!哈哈,是的,实际上我习惯了C++和C语言,所以,如果对我来说似乎是正确的XXEPPLICATION一个答案,它给出了许多IF的替代,比如开关语句:- Lua没有开关语句。