Advertisement
Guest User

startup

a guest
Sep 21st, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. os_pullEvent = os.pullEvent
  2. os.pullEvent = os.pullEventRaw
  3.  
  4. local pd = peripheral.find("player_detector")
  5.  
  6. local w,h = term.getSize()
  7. local welcome = {
  8.   "Welcome to",
  9.   "InputUsername's computer.",
  10.   "",
  11.   "Please identify yourself.",
  12. }
  13. local access = {
  14.   "Access granted.",
  15.   "Hello, %s.",
  16. }
  17. local noaccess = {
  18.   "Access denied.",
  19.   "Nice try, %s.",
  20. }
  21.  
  22. local whitelist = {
  23.   ["InputUsername"] = true,
  24.   ["Lollonator"] = true,
  25.   ["valithor2"] = true,
  26. }
  27.  
  28. term.setBackgroundColor(colors.white)
  29.  
  30. while true do
  31.   term.setTextColor(colors.lightGray)
  32.   term.clear()
  33.  
  34.   for i=1,#welcome do
  35.     term.setCursorPos(w/2-#welcome[i]/2+1,h/2-#welcome/2-1+i)
  36.     textutils.slowPrint(welcome[i],25)
  37.   end
  38.  
  39.   local e,_,p = os.pullEvent("player")
  40.   if (whitelist[p] == true) then
  41.     sleep(.5)
  42.     term.setTextColor(colors.black)
  43.     for i=1,#access do
  44.       local s = access[i]:format(p)
  45.       term.setCursorPos(w/2-#s/2+1,h/2+#welcome/2+1+i)
  46.       textutils.slowPrint(s)
  47.     end
  48.     sleep(.5)
  49.     break
  50.   else
  51.     sleep(.5)
  52.     term.setTextColor(colors.black)
  53.     for i=1,#noaccess do
  54.       local s = noaccess[i]:format(p)
  55.       term.setCursorPos(w/2-#s/2+1,h/2+#welcome/2+1+i)
  56.       textutils.slowPrint(s)
  57.     end
  58.   end
  59. end
  60.  
  61. term.setBackgroundColor(colors.black)
  62. term.setCursorPos(1,1)
  63. term.clear()
  64.  
  65. os.pullEvent = os_pullEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement