FFGFlash

.login

Sep 14th, 2021 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. local App = app.new()
  2. App.EventHandler:disconnectAll("terminate")
  3.  
  4. local timer = nil
  5.  
  6. local c,b = "00000877", "ffffffff"
  7. if term.isColor() then c, b = "00000bde", "77777777" end
  8.  
  9. local password, passwordDisplay = "", ""
  10.  
  11. App.EventHandler:connect("char", function(char)
  12.   password = password..char
  13.   passwordDisplay = passwordDisplay.."*"
  14. end)
  15.  
  16. App.EventHandler:connect("key_up", function(key)
  17.   if key == keys.enter then
  18.     if md5.calc(password) ~= _G.User.Password then
  19.       term.setCursorPos(1,4)
  20.       print("Incorrect Password.")
  21.       sleep(1)
  22.       password = ""
  23.       passwordDisplay = ""
  24.       return
  25.     end
  26.     App:stop()
  27.   elseif key == keys.backspace then
  28.     password = string.sub(password,1,-2)
  29.     passwordDisplay = string.sub(passwordDisplay,1,-2)
  30.   end
  31. end)
  32.  
  33. App.EventHandler:connect("timer", function(completed)
  34.   if completed ~= timer then return end
  35.   shell.switchTab(1)
  36.   timer = os.startTimer(1/30)
  37. end)
  38.  
  39. App.EventHandler:connect("app_closed", function(app)
  40.   apps = data.load("/.apps")
  41.   local id = apps[app][3]
  42.   for code,data in pairs(apps) do
  43.     if data[3] and (not id or data[3] > id) then
  44.       apps[code][3] = data[3] - 1
  45.     end
  46.   end
  47.   if id then apps[app][3] = -1 end
  48.   data.save("/.apps", apps)
  49. end)
  50.  
  51. function App:draw()
  52.   term.setTextColor(_G.TextColor)
  53.   term.setBackgroundColor(_G.BackgroundColor)
  54.   term.clear()
  55.   term.setCursorPos(1,1)
  56.   term.blit("nekOS///",c,b)
  57.   term.write(" ".._G.User.Username)
  58.   term.setCursorPos(1,2)
  59.   term.write("Password> "..passwordDisplay)
  60. end
  61.  
  62. function App:stopped()
  63.   shell.run(".menu")
  64. end
  65.  
  66. timer = os.startTimer(1/30)
  67. App:start()
Add Comment
Please, Sign In to add comment