Advertisement
chikcken

PowOS system SignIn FIXED (Minecraft OpenComputers)

May 7th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.32 KB | None | 0 0
  1. local fs = require("filesystem")
  2. local term = require("term")
  3. local comp = require("component")
  4. local pc = require("computer")
  5. local event = require("event")
  6. local text = require("text")
  7. local gpu = comp.gpu
  8.  
  9. function Startup()
  10.     gpu.setBackground(0xaaaaFF)
  11.     gpu.setForeground(0x000000)
  12.     print("                                                                                ")
  13.     print("                                                                                ")
  14.     print("                                                                                ")
  15.     print("                                                                                ")
  16.     print("                                                                                ")
  17.     print("                                                                                ")
  18.     print("                                                                                ")
  19.     print("                                                                                ")
  20.     print("                                                                                ")
  21.     print("                                                                                ")
  22.     print("                                                                                ")
  23.     print("                                                                                ")
  24.     print("                                                                                ")
  25.     print("                                                                                ")
  26.     print("                                                                                ")
  27.     print("                                                                                ")
  28.     print("                                                                                ")
  29.     print("                                                                                ")
  30.     print("                                                                                ")
  31.     print("                                                                                ")
  32.     print("                                                                                ")
  33.     print("                                                                                ")
  34.     print("                                                                                ")
  35.     print("                                                                                ")
  36.     print("                                                                                ")
  37.     S = 0
  38.     DrawSignInWindow(S)
  39. end
  40. function DrawSignInWindow(Stage)
  41.     -- draw Window
  42.     term.setCursor(15,7)
  43.     gpu.setBackground(0xbbbbbb)
  44.     print("                                                ")
  45.     gpu.setBackground(0x0000ff)
  46.     term.setCursor(15,8)
  47.     gpu.setBackground(0x0000FF)
  48.     print("                                                ")
  49.     term.setCursor(15,9)
  50.     print("                                                ")
  51.     term.setCursor(15,10)
  52.     print("                                                ")
  53.     term.setCursor(15,11)
  54.     gpu.setBackground(0x0000ff)
  55.     print("                                                ")
  56.     term.setCursor(15,12)
  57.     print("                                                ")
  58.     term.setCursor(15,13)
  59.     print("                                                ")
  60.     term.setCursor(15,14)
  61.     print("                                                ")
  62.     term.setCursor(15,15)
  63.     print("                                                ")
  64.     term.setCursor(15,16)
  65.     print("                                                ")
  66.     term.setCursor(15,17)
  67.     print("                                                ")
  68.     gpu.setBackground(0x0000ff)
  69.     if Stage == 0 then
  70.         DrawPass()
  71.     elseif Stage == 1 then
  72.         Fail1()
  73.     elseif Stage == 2 then
  74.         Fail2()
  75.     elseif Stage == 3 then
  76.         Success1()
  77.     end
  78. end
  79. function DrawPass()
  80.     term.setCursor(15,9)
  81.     gpu.setForeground(0xffffff)
  82.     print("Please enter your password")
  83.     term.setCursor(15,10)
  84.     print("Leave it blank for no password")
  85.     term.setCursor(15,11)
  86.     gpu.setForeground(0xFFAA00)
  87.     print("RE-TIP: Remember to hit enter when you done")
  88.     term.setCursor(15,12)
  89.     gpu.setForeground(0xffffff)
  90.     print("After 'enter' you will be logged in if correct")
  91.     gpu.setForeground(0x000000)
  92.     term.setCursor(15,14)
  93.     gpu.setBackground(0xffffff)
  94.     print("                                                ")
  95.     Password()
  96. end
  97. function Password()
  98.     term.setCursor(15,14)
  99.     pass = text.trim(term.read(nil, false, nil, "*"))
  100.     local CheckForUser = fs.list("/PowOS/user/")
  101.     User = CheckForUser()
  102.     checkForPass = io.open("/PowOS/user/"..User, "r")
  103.     checkForPass = checkForPass:read("*all")
  104.     if checkForPass ~= nil and pass == checkForPass then
  105.         Stagey = 3
  106.         DrawSignInWindow(Stagey)
  107.     elseif checkForPass == nil and pass == "" then
  108.         Stagey = 3
  109.         DrawSignInWindow(Stagey)
  110.     else
  111.         Stagey = 1
  112.         DrawSignInWindow(Stagey)
  113.     end
  114. end
  115. function Fail1()
  116.     term.setCursor(15,9)
  117.     gpu.setForeground(0xff0000)
  118.     print("FAILED")
  119.     term.setCursor(15,10)
  120.     gpu.setForeground(0xffffff)
  121.     print("Invalid password!")
  122.     term.setCursor(15,11)
  123.     gpu.setForeground(0xFFAA00)
  124.     print("TIP: Lost your password? try reinstall the OS")
  125.     term.setCursor(15,12)
  126.     gpu.setForeground(0xffffff)
  127.     term.setCursor(15,16)
  128.     gpu.setBackground(0x0000AA)
  129.     print("[RETRY]")
  130.     term.setCursor(53,16)
  131.     print("[SHUTDOWN]")
  132.     Fail1_touch()
  133. end
  134. function Fail1_touch()
  135.     local _,_,x,y = event.pull("touch")
  136.     if x >= 53 and y == 16 and x <= 63 then
  137.         term.setCursor(1,1)
  138.         gpu.setBackground(0x000000)
  139.         gpu.setForeground(0xffffff)
  140.         term.clear()
  141.         pc.shutdown(false)
  142.     elseif x >= 15 and y == 16 and x <= 22 then
  143.         Startup()
  144.     else
  145.         Fail1_touch()
  146.     end
  147. end
  148. function Fail2()
  149.     term.setCursor(15,9)
  150.     gpu.setForeground(0xff0000)
  151.     print("FAILED")
  152.     term.setCursor(15,10)
  153.     gpu.setForeground(0xffffff)
  154.     print("Password isn't correct!")
  155.     term.setCursor(15,11)
  156.     gpu.setForeground(0xFFAA00)
  157.     print("TIP: Lost your password? try reinstall the OS")
  158.     term.setCursor(15,12)
  159.     gpu.setForeground(0xffffff)
  160.     term.setCursor(15,16)
  161.     gpu.setBackground(0x0000AA)
  162.     print("[RETRY]")
  163.     term.setCursor(53,16)
  164.     print("[SHUTDOWN]")
  165.     print(checkforPass)
  166.     Fail1_touch()
  167. end
  168. function Success1()
  169.     term.setCursor(1,1)
  170.     gpu.setBackground(0x000000)
  171.     gpu.setForeground(0xffffff)
  172.     term.clear()
  173.     os.execute("/PowOS/system/Desktop.lua")
  174. end
  175. Startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement