Advertisement
Redxone

[CC - Logsys] - DoorLock

May 18th, 2016
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.83 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. os.loadAPI("ugapi")
  3. os.loadAPI("sha256")
  4. os.loadAPI("logapi")
  5. rednet.open(logapi.getModemSide())
  6. local protocol = ""
  7. local it = ".simg"
  8. local w, h = term.getSize()
  9. local scp = term.setCursorPos
  10. local sbc = term.setBackgroundColor
  11. local stc = term.setTextColor
  12. function notify(title,txt,txtone,txttwo)
  13.   local w, h = term.getSize()
  14.   paintutils.drawBox(
  15.     (w/2) - 9, (h/2) - 2, (w/2)+12, (h/2)+2,
  16.     colors.black)
  17.   paintutils.drawFilledBox(
  18.     (w/2) - 10, (h/2) - 3, (w/2)+11, (h/2)+1,
  19.     colors.lightGray)
  20.   term.setBackgroundColor(colors.blue)
  21.   term.setTextColor(colors.white)
  22.   paintutils.drawLine((w/2)-10,(h/2)-3,(w/2)+11,(h/2)-3)
  23.   term.setCursorPos((w/2)-10,(h/2)-3)
  24.   write(title)
  25.   term.setBackgroundColor(colors.lightGray)
  26.   term.setCursorPos((w/2)-10,(h/2)-2)
  27.   write(txt)
  28.   term.setCursorPos((w/2)-10,(h/2)-1)
  29.   write(txtone)
  30.   term.setCursorPos((w/2)-10,(h/2))
  31.   write(txttwo)
  32.   os.pullEvent("key")
  33. end
  34. function ui()
  35.   ugapi.bcolor(colors.lightBlue)
  36.   term.clear()
  37.   ugapi.drawimage(it,2,1)
  38.   scp(13,5)
  39.   stc(colors.white)
  40.   sbc(colors.blue)
  41.   write("Please sign in to continue. ")
  42.   sbc(colors.lightGray)
  43.   scp(14,10)
  44.   write("User: ")
  45.   scp(14,12)
  46.   write("Pass: ")
  47.   scp(20,10)
  48.   stc(colors.black)
  49.   sbc(colors.white)
  50.   local uname = read()
  51.   scp(20,12)
  52.   local upass = read("*")
  53.   local isvalid = logapi.checkLogin(protocol,uname,upass)
  54.   if(isvalid == "no-connection")then notify("Login","Server connection has","been lost. ","") return ui() end
  55.   if(isvalid == true)then
  56.      notify("Login","Access granted.","Press any key to","open door. ")
  57.      rs.setOutput("left", true)
  58.      sleep(2)
  59.      rs.setOutput("left",false)
  60.      ui()
  61.   elseif(isvalid == false)then
  62.       notify("Login","Unknown account or","invalid password. ","")
  63.       ui()
  64.   end
  65. end
  66. ui()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement