Advertisement
atlasim

atlasoss login stystem

Oct 29th, 2023
1,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. -- AtlasOS Login System
  2.  
  3. local users = { {"user1", "user1"}, {"user2", "user2"} }
  4. local loggedin = false
  5. old_terminate = os.pullEvent
  6. os.pullEvent = os.pullEventRaw
  7. currentuser = "none"
  8.  
  9. function titlebar(title)
  10.     term.clear()
  11.     term.setTextColor(colors.yellow)
  12.     term.setCursorPos(1,1)
  13.     term.write(title)
  14.     term.setTextColor(colors.white)
  15.     term.setCursorPos(1,2)
  16. end
  17.  
  18. while loggedin == false do
  19.     titlebar("Login")
  20.     term.setCursorPos(1,2)
  21.  
  22.     term.write("Username > ")
  23.     local user = read()
  24.  
  25.     term.setCursorPos(1,3)
  26.     local pass = read("*")
  27.  
  28.     for _,u in pairs(users) do
  29.         if user == "shutdown" then
  30.             os.shutdown()
  31.         elseif (user == u[1]) and (pass == u[2]) then
  32.             term.clear()
  33.             temr.setCursorPos(1,1)
  34.             os.pullEvent = old_terminate
  35.             currentuser = u[1]
  36.             shell.run("/rom/programs/shell.lua")
  37.             os.pullEvent = os.pullEventRaw
  38.             currentuser = "none"
  39.         else
  40.             local a = 1
  41.         end
  42.     end
  43. end
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement