Advertisement
AlexMastang

ComputerCraft Redstone Security Program

Jan 3rd, 2023 (edited)
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. --[[
  2.  
  3. Made by Alexmaster75
  4. This program allows the player to activate a redstone
  5. contraption by a username and password protection.
  6. Download this with the command "pastebin get BQgDkJve startup.lua"
  7. and reboot. This will make the computer load the program every time
  8. it is started up. Change the US and PW variables content to
  9. personalize the program and make it more secure.
  10.  
  11. ]]--
  12.  
  13. local monitor = peripheral.find("monitor")
  14. local US = "Username"
  15. local PW = "admin"
  16. local user = ""
  17. local pwd = ""
  18.  
  19. if monitor then
  20.     term.redirect(monitor)
  21. end
  22.  
  23. local w,h = term.getSize()
  24.  
  25. term.clear()
  26. term.setCursorPos(1,1)
  27. print("LIMITED ACCESS ZONE")
  28. for i=1,w do
  29.     write("-")
  30. end
  31. print()
  32. textutils.slowWrite("Username: ")
  33. user = read()
  34. textutils.slowWrite("Password: ")
  35. pwd = read("*")
  36.  
  37. local x,y = term.getCursorPos()
  38.  
  39. while true do
  40.     term.setCursorPos(1,y)
  41.     if user == US and pwd == PW then
  42.         textutils.slowWrite("ACCESS GRANTED")
  43.         -- Pay attention to this part as it is the redstone output.
  44.         -- Change the "..." to ant name like left, right, top, bottom, ...
  45.         rs.setOutput("left", true)
  46.         os.sleep(4)
  47.         rs.setOutput("left", false)
  48.         -- /\
  49.     else
  50.         textutils.slowWrite("Username or Password not correct, please retry...")
  51.         os.sleep(8)
  52.     end
  53.     os.reboot()
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement