luacomputercraft

lua <eof> expected near end


I'm trying to make a keycard door in minecraft using computercraft and it gives me an error at line 23 saying expected

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

Solution

  • There is an extra end after the break at line 14. It closes the conditional block prematurely. You are getting this error message because the end at the bottom of the file has nothing to close.