superkh

Login Script

Sep 15th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1. --Vars-------------------------------------------------------------------
  2. os.pullEvent = os.pullEventRaw
  3. local w,h = term.getSize()
  4. local run = true
  5. local Ulist = fs.list("os/users")
  6. local User = nil
  7. local conf = nil
  8. local bufBoot = buf.createBuffer()
  9. --------------------------------------------------------------------------
  10. local function dsFirst()
  11.     buf.bc(colors.blue)
  12.     buf.clsB(bufBoot)
  13.     buf.drawImage(bufBoot,1,1,"os/images/boot")
  14.     ---------
  15.     buf.tc(colors.blue)
  16.     buf.pos(21,6)
  17.     buf.bc(colors.black)
  18.     buf.bWriteL(bufBoot,"User:")
  19.     buf.pos(21,8)
  20.     buf.bWriteL(bufBoot,"Pass:")
  21. end
  22. local function ds()
  23.     buf.drawBuffer(bufBoot)
  24.     term.setBackgroundColor(colors.black)
  25.     term.setTextColor(colors.blue)
  26. end
  27. local function user()
  28.   term.setCursorPos(26,6)
  29.   local I = io.read()
  30.   for v,k in ipairs(Ulist) do
  31.     if I==k then
  32.         User = k
  33.         A.LoadConf(User)
  34.         conf = A.getT(A.RCpath())
  35.         return true
  36.     end
  37.   end
  38.   return false
  39. end
  40. local function pass()
  41.   term.setCursorPos(26,8)
  42.   local pass = conf["PW"]
  43.   local I = read("*")
  44.   if I==pass then
  45.     return true
  46.   else
  47.     return false
  48.   end
  49. end
  50. local function userin()
  51.     local times = 0
  52.     local run = true
  53.     while run do
  54.         local s = user()
  55.         if s == true then
  56.             run = falses
  57.             buf.pos(26,6)
  58.             buf.bWriteL(bufBoot,User)
  59.         else
  60.             ds()
  61.         end
  62.     end
  63.     run = true
  64.     sleep(.05)
  65.     while run do
  66.         if times<3 then
  67.             local s = pass()
  68.             if s==true then
  69.                 break
  70.             else
  71.                 times = times+1
  72.             end
  73.         else
  74.             os.reboot()
  75.         end
  76.         ds()
  77.     end
  78.     return true
  79. end
  80. local function loadBufs()
  81.     A.createbufs(file)
  82. end
  83. --------------------------------------------------------------------------
  84. local function main()
  85.     dsFirst()
  86.     ds()
  87.     userin()
  88.     loadBufs()
  89.     return true
  90. end
  91.  
  92. local ok, err = pcall(main)
  93. if not ok then
  94.     A.Error(err)
  95. else
  96.     if User == "Admin" then
  97.         shell.run("os/APIS/manage")
  98.     else
  99.         shell.run("os/os")
  100.     end
  101. end
Add Comment
Please, Sign In to add comment