IF ELSE IF END 给出 Unclosed Function 错误

IF ELSE IF END gives Unclosed Function error

第一次看PICO-8

这个简单的 IF 语句给我错误 "UNCLOSED FUNCTION AT LINE 1"。

function MYTEST() 
  local x = 1
  if x==1 then
    print("x==1")
  else if x==0 then
    print("x==0")
  end
end

我承认这个函数没有用,但是解释器不允许运行。

为什么?

如评论中所述,将代码从 else if 更改为 elseif 即可。

或者,在第一个 end 之前添加一个 end:

function MYTEST() 
  local x = 1
  if x==1 then
    print("x==1")
  else if x==0 then
      print("x==0")
    end
  end
end