Advertisement
Guest User

login.lua

a guest
May 15th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.57 KB | None | 0 0
  1. require("/scripts/auth/auth")
  2.  
  3. local oldPull = os.pullEvent
  4. os.pullEvent = os.pullEventRaw
  5.  
  6. function resetCursor(x, y)
  7.  term.clear()
  8.  term.setCursorPos(x, y)
  9. end
  10.  
  11. local auth = false
  12. resetCursor(1, 1)
  13. while not auth do
  14.     io.write("Username: ")
  15.  local username = string.gsub(read(), "^ +", "")
  16.  username = string.gsub(username, " +$", "")
  17.     io.write("Password: ")
  18.     local password = read("*")
  19.  local res = verify_user(username, password)
  20.  auth = res.allow
  21.  print(res.loginMessage)
  22.  if not auth then
  23.   sleep(2)
  24.   resetCursor(1, 1)
  25.  end
  26. end
  27.  
  28. os.pullEvent = oldPull
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement