Advertisement
Guest User

lock

a guest
May 15th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.57 KB | None | 0 0
  1. --os.pullEvent = os.pullEventRaw
  2. local monitor = peripheral.find("monitor")
  3. pro = shell.getRunningProgram()
  4. function lock()
  5.   if fs.exists(userNameFile) then
  6.     local file = fs.open(userNameFile, "r")
  7.     user = file.readLine()
  8.   end
  9.   if fs.exists(passFile) then
  10.     local file = fs.open(passFile, "r")
  11.     pass = file.readLine()
  12.   if prompt == nil then
  13.     term.clear()
  14.     term.setCursorPos(1,1)
  15.     textutils.slowPrint("Hello, what would you like your username to be?")
  16.     userInput = term.setTextColor(colors.yellow)
  17.     userInput = read()
  18.     term.setTextColor(colors.white)
  19.     -------------------------------------
  20.     while true do
  21.       userNameFile = tostring(math.random(1,65535))
  22.       if not fs.exists(userNameFile) then
  23.         local file = fs.open(userNameFile, "w")
  24.         file.write(userInput)
  25.         file.close()
  26.         break
  27.       end
  28.     end
  29.     -------------------------------------
  30.     textutils.slowPrint("Hello ", user, ". What would you like your password to be?")
  31.     passInput = term.setTextColor(colors.yellow)
  32.     passInput = read()
  33.     term.setTextColor(colors.white)
  34.     -------------------------------------
  35.     while true do
  36.       passFile = tostring(math.random(1,65535))
  37.       if not fs.exists(passFile) then
  38.         local file = fs.open(passFile, "w")
  39.         file.write(passInput)
  40.         file.close()
  41.         break
  42.       end
  43.     end
  44.     -------------------------------------
  45.     textutils.slowPrint("What would you like your message to say before displaying your login prompt?")
  46.     promptInput = term.setTextColor(colors.yellow)
  47.     promptInput = read()
  48.     term.setTextColor(colors.white)
  49.     -------------------------------------
  50.     while true do
  51.       promptFile = tostring(math.random(1,65535))
  52.       if not fs.exists(promptFile) then
  53.         local file = fs.open(promptFile)
  54.         file.write(promptInput)
  55.         file.close()
  56.         break
  57.       end
  58.     end
  59.     -------------------------------------
  60.     textutils.slowPrint("Okay, setup finished, reloading in 2 seconds")
  61.     sleep(2)
  62.     lock()
  63.   end
  64.   if peripheral.find("monitor") then
  65.     monitor.setTextScale(3)
  66.     monitor.setBackgroundColor(colors.red)
  67.     monitor.clear()
  68.     monitor.setCursorPos(2,5)
  69.     monitor.write("Currently Locked")
  70.   end
  71.   term.clear()
  72.   term.setCursorPos(1,1)
  73.   term.setTextColor(colors.yellow)
  74.   textutils.slowPrint(mess)
  75.   term.setTextColor(colors.white)
  76.   sleep(1)
  77.   textutils.slowWrite("Username: ")
  78.   input1= term.setTextColor(colors.yellow)
  79.   input1 = read()
  80.   term.setTextColor(colors.white)
  81.   textutils.slowWrite("Password: ")
  82.   input2 = term.setTextColor(colors.yellow)
  83.   input2 = read("*")
  84.   if user == input1 and pass == input2 then
  85.     if peripheral.find("monitor") then
  86.       monitor.setTextScale(3)
  87.       monitor.setBackgroundColor(colors.green)
  88.       monitor.clear()
  89.       monitor.setCursorPos(2,5)
  90.       monitor.write("Currently Unlocked")
  91.     end
  92.     term.setTextColor(colors.green)
  93.     term.setCursorPos(1,4)
  94.     term.slowPrint("Valid Login Credentials. Welcome to the System.")
  95.     sleep(2)
  96.     term.clear()
  97.     term.setCursorPos(1,1)
  98.     term.setTextColor(colors.yellow)
  99.     print(os.version())
  100.     term.setCursorPos(1,2)
  101.   else
  102.     term.setCursorPos(1,4)
  103.     term.setTextColor(colors.red)
  104.     textutils.slowPrint("Invalid Login Credenials, Please Don't Try Again.")
  105.     sleep(2)
  106.     lock()
  107.   end
  108. end
  109.  
  110. if not fs.exists("startup") then
  111.   file = fs.open("startup", "w")
  112.   file.write("shell.run(\"")
  113.   file.write(pro)
  114.   file.write("\")")
  115.   file.close()
  116.   os.reboot()
  117. end
  118.  
  119. lock()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement