Advertisement
AnonGaming

Untitled

Mar 3rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local userInterface = {}
  2.  
  3.  
  4.  
  5. function userInterface.init(side,ranks)
  6.    
  7.     userInterface.ranks = ranks
  8.     rednet.open(side)
  9.     rednet.broadcast("userServer")
  10.     senderID,message = rednet.receive(10)
  11.    
  12.     userInterface.serverID = senderID
  13.    
  14. end
  15.  
  16. function userInterface.login(user,pass)
  17.    
  18.     rednet.send(userInterface.serverID,"auth "..user.." "..pass.." "..userInterface.ranks)
  19.    
  20.     senderID,message = rednet.receive(10)
  21.    
  22.     if message == "Correct" then
  23.         return true
  24.     end
  25.     return false
  26. end
  27.  
  28.  
  29.  
  30. function openDoor()
  31.     redstone.setOutput("bottom",true)
  32.     sleep(3)
  33.     redstone.setOutput("bottom",false)
  34. end
  35.  
  36.  
  37. function closeDoor()
  38.     redstone.setOutput("bottom",false)
  39. end
  40.  
  41.  
  42. -- ranks = "owner,admin,mod,user"
  43.  
  44. userInterface.init("back","owner")
  45.  
  46. while true do
  47.     term.clear()
  48.     term.setCursorPos(1,1)
  49.     print("========User Logon=========")
  50.     print("Version: 1.0")
  51.     print("Username: ")
  52.     local username = read()
  53.     print("Password: ")
  54.     local pass = read("*")
  55.    
  56.     local authed = userInterface.login(username,pass)
  57.    
  58.     if authed == false then
  59.         openDoor()
  60.     else
  61.         closeDoor()
  62.     end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement