if,else,else if和end Lua

Mak*_*shi 27 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
                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")
Run Code Online (Sandbox Code Playgroud)

我得到的错误是'结束'预期(在第273行关闭'if')'else'附近

另外,在每个if之后添加end(这不是应该做的但是无论如何都尝试过)不起作用......

如果你需要我翻译成英文我很乐意做评论和一切,但我认为这不是这个问题的必要条件.

Mar*_*rot 52

elseif,不是else if(注意空间).错误是因为解释器期望end每个else块.

有关详细信息,请参阅手册.