Advertisement
Guest User

Login

a guest
Jan 8th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.39 KB | None | 0 0
  1. local tab = 0
  2. term.setTextColor(colors.black)
  3. user = ""
  4. pass = ""
  5. if term.isColor() then
  6.   paintutils.drawFilledBox(1,1,51,3,colors.orange)
  7.   paintutils.drawFilledBox(1,4,51,19,colors.white)
  8.   paintutils.drawImage(paintutils.loadImage("FireOS/32/Pictures/logoSmall.pu"),1,4)
  9.   paintutils.drawLine(1,3,51,3,colors.black)
  10.   paintutils.drawBox(9,4,11,19,colors.black)
  11.   paintutils.drawLine(10,3,10,19,colors.orange)
  12.   paintutils.drawBox(13,7,50,9,colors.black)
  13.   paintutils.drawBox(13,12,50,14,colors.black)
  14. else
  15.   paintutils.drawFilledBox(1,1,51,3,colors.lightGray)
  16.   paintutils.drawFilledBox(1,4,51,19,colors.white)
  17.   basic.drawImage(basic.loadImage("FireOS/32/Pictures/logoSmall.pu"),1,4)
  18.   paintutils.drawLine(1,3,51,3,colors.black)
  19.   paintutils.drawBox(9,4,11,19,colors.black)
  20.   paintutils.drawLine(10,3,10,19,colors.lightGray)
  21.   paintutils.drawBox(13,7,50,9,colors.black)
  22.   paintutils.drawBox(13,12,50,14,colors.black)
  23. end
  24. term.setBackgroundColor(colors.white)
  25. term.setCursorPos(13,6)
  26. write("Enter Username")
  27. term.setCursorPos(13,11)
  28. write("Enter Password")
  29. local file = fs.open("FireOS/32/User","r")
  30. local userC = file.readLine()
  31. local passC = file.readLine()
  32. local passKey = "\7"
  33. if userC == "Momboggins" then
  34.   passKey = "\3"
  35. end
  36.   local function a()
  37.     while true do
  38.       local event, button, x, y = os.pullEvent()
  39.       if event == "key" then
  40.         if button == keys.tab then
  41.           os.queueEvent("key",keys.enter)
  42.           if tab == 2 then
  43.             tab = 1
  44.           else
  45.             tab = 2
  46.           end
  47.         elseif button == keys.enter and tab == 0 then
  48.           tab = 1
  49.         elseif button == keys.enter and pass ~= "" and user ~= "" then
  50.           if user == userC and pass == passC then
  51.             if term.isColor() then
  52.               term.setBackgroundColor(colors.orange)
  53.             end
  54.             term.clear()
  55.             sleep(0)
  56.             ks.center("Welcome...",true)
  57.             shell.run("FireOS/32/Desk")
  58.             break
  59.           else
  60.             if term.isColor() then
  61.               term.setBackgroundColor(colors.orange)
  62.             end
  63.             term.clear()
  64.             ks.center("Your username or password was incorrect!",true)
  65.             sleep(0.6)
  66.             os.reboot()
  67.           end    
  68.         end
  69.       end
  70.     end
  71.   end
  72.   local function c(str)
  73.     for i = 1,#str do
  74.       os.queueEvent("char",string.sub(str,i,i))
  75.     end
  76.   end
  77.   local function b()
  78.     while true do
  79.       if tab == 1 then
  80.         term.setCursorPos(14,8)
  81.         if tabChar ~= 1 then
  82.           parallel.waitForAll(function()
  83.           user = read()
  84.           tab = 2
  85.           end,
  86.           function()
  87.           sleep(0.1)
  88.           c(user)
  89.           end)
  90.           tabChar = 1
  91.         else
  92.           user = read()
  93.         end
  94.       elseif tab == 2 then
  95.         term.setCursorPos(14,13)
  96.         if tabChar ~= 2 then
  97.           parallel.waitForAll(function()
  98.           pass = read(passKey)
  99.           tab = 3
  100.           tabChar = 2
  101.           end, function()
  102.           sleep(0.1)
  103.           c(pass)
  104.           end)
  105.         else
  106.           pass = read(passKey)
  107.         end
  108.       end
  109.       sleep(0)
  110.     end
  111.   end
  112. while true do
  113.   sleep(0)
  114.   parallel.waitForAny(a,b)
  115.   term.setBackgroundColor(colors.black)
  116.   term.setTextColor(colors.white)
  117.   term.clear()
  118.   term.setCursorPos(1,1)
  119.   print("Something went wrong!!")
  120.   break
  121. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement