Advertisement
Guest User

<eof> is infuriating

a guest
Apr 19th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #!/bin/lua
  2.  
  3. local component = require("component")
  4. local computer = require("computer")
  5. local text = require("text")
  6. local unicode = require("unicode")
  7. local pin = "1234"
  8.  
  9. if not component.isAvailable("gpu") then
  10. return
  11. end
  12. local lines = {_OSVERSION .. " (" .. math.floor(computer.totalMemory() / 1024) .. "k RAM)"}
  13. local maxWidth = unicode.len(lines[1])
  14. local f = io.open("/usr/misc/greetings2.txt")
  15. if f then
  16. local greetings = {}
  17. pcall(function()
  18. for line in f:lines() do table.insert(greetings, line) end
  19. end)
  20. f:close()
  21. local greeting = greetings[math.random(1, #greetings)]
  22. if greeting then
  23. local width = math.max(10, component.gpu.getResolution())
  24. for line in text.wrappedLines(greeting, width - 4, width - 4) do
  25. table.insert(lines, line)
  26. maxWidth = math.max(maxWidth, unicode.len(line))
  27. end
  28. end
  29. end
  30.  
  31. ::pin_enter::
  32. print("Please enter the correct PIN to unlock door.")
  33. local inputvar = term.write(tostring(env._PROMPT or "pin "))
  34. if inputvar == pin then
  35. goto correct
  36. end
  37. else
  38. print("Incorrect.")
  39. goto pin_enter
  40. end
  41. ::correct::
  42. print("Correct.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement