craniumkid22

Generic Password Door

Sep 25th, 2012
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. local function loadUser()
  2.     local loadTable = {}
  3.     local file = fs.open(".pass", "r")
  4.     if file then
  5.         readLine = file.readLine()
  6.         while readLine do
  7.             local lineTable = {}
  8.             lineTable.user, lineTable.pass = string.match(readLine, "(%w+),(%w+)")
  9.             if lineTable.type then
  10.                 table.insert(loadTable, lineTable)
  11.             end
  12.             readLine = file.readLine()
  13.         end
  14.         file.close()
  15.     end
  16.     return loadTable
  17. end
  18.  
  19. --user check
  20. local username,password = loadUser()
  21. if usernamd == nil and password == nil then
  22.     term.clear()
  23.     term.setCursorPos(1,1)
  24.     write("Please choose your Username: ")
  25.     local user = read()
  26.     term.clear()
  27.     term.setCursorPos(1,1)
  28.     write("Please choose your Password: ")
  29.     local pass = read("*")
  30.     local file = fs.open(".password","w")
  31.     file.write(user..","..pass)
  32.     file.close()
  33. else
  34.     while true do
  35.         term.clear()
  36.         termsetCursorPos(1,1)
  37.         write("Please enter Username: ")
  38.         local user = read()
  39.         term.clear()
  40.         term.setCursorPos(1,1)
  41.         write("Please enter Password: ")
  42.         local pass = read("*")
  43.         if user == username and pass = password then
  44.             redstone.setOutput("left",true)
  45.             redstone.setOutput("right",true)
  46.             sleep(3)
  47.             redstone.setOutput("right",false)
  48.             redstone.setOutput("left",false)
  49.         end
  50.     end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment