Guest User

Untitled

a guest
Sep 19th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. -- os.pullEvent = os.pullEventRaw
  2. local w,h = term.getSize()
  3. local dSide = "right"
  4. local sID = 90
  5. local rSide = "back"
  6. local uAllow = false
  7. local pAllow = false
  8. function clear() term.clear() term.setCursorPos(1,1) end
  9. local function uInput()
  10.   write("Username: ")
  11.   uInput = read()
  12.   rednet.send(sID, uInput)
  13.   uId, uMsg = rednet.receive(2)
  14.   if uId == sID and uMsg == "uAllow" then
  15.     uAllow = true
  16.   else
  17.     print("Incorrect Username!")
  18.     sleep(2)
  19.     os.reboot()
  20.   end
  21. end
  22. local function pInput()
  23.   write("Password: ")
  24.   pInput = read("*")
  25.   rednet.send(sID, pInput)
  26.   pId, pMsg = rednet.receive(2)
  27.   if pId == sID and pMsg == "pAllow" then
  28.     pAllow = true
  29.   else
  30.     print("Incorrect Password!")
  31.     sleep(2)
  32.     os.reboot()
  33.   end
  34. end
  35. local function printCentered(str, h)
  36.   term.setCursorPos(w/2 - #str/2, h)
  37.   write(str)
  38. end
  39. local function drawHeader()
  40.   clear()
  41.   printCentered("Sammich Login", 1)
  42. end
  43. rednet.open(rSide)
  44. drawHeader()
  45. term.setCursorPos(1,5)
  46. uInput()
  47. if uAllow == true then
  48.   term.setCursorPos(1,6)
  49.   pInput()
  50. end
  51. if uAllow and pAllow == true then
  52.   redstone.setOutput(dSide, true)
  53.   sleep(5)
  54.   redstone.setOutput(dSide, false)
  55.   rednet.close(rSide)
  56.   os.reboot()
  57. end
Add Comment
Please, Sign In to add comment