lua <eof> 期望在 end 附近

我正在尝试使用 Computercraft 制作 Minecraft 中的钥匙卡门,但是在第23行中出现了一个错误,提示期望

rs.setOutput("bottom", true)
while true do
  if disk.isPresent("top") then
    if fs.exists("disk/.cardauth/authkey") then
      f = fs.open("disk/.cardauth/authkey", "r")
      p = f.readAll()
      if p == "UDoFk6ErYM" then
        disk.eject("top")
        rs.setOutput("bottom", false)
        sleep(4)
        rs.setOutput("bottom", true)
      elseif p == "QmwZNWQsxFug6SMOYQnh" then
        disk.eject("top")
        break end
      else
        disk.eject("top")
      end
    else
      disk.eject("top")
    end
  end
  sleep(0.1)
end
点赞
用户796375
用户796375

在第14行break之后多了一个end。它过早地关闭了条件块。你看到这个错误消息是因为文件底部的end没有需要关闭的内容。

2019-04-07 07:45:14