KOD_28

LockDoor - KOD_28

Feb 22nd, 2013
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.12 KB | None | 0 0
  1. -- This code is copirighted and made by KOD_28 !
  2. -- If you use publically you must quote its author
  3.  
  4. -- This code is meant to be used with the mod ComputerCraft for Minecraft
  5.  
  6. -- Before using the program you must go to root directory ( cd / )
  7. -- Then create a data directory ( mkdir data )
  8. -- then go in it ( cd data ) and create a pswd file ( edit pswd )
  9. -- Inside pswd just write your password and save/exit the file
  10. -- Then you can run the program and have fun with it ;)
  11.  
  12. local pullEvent = os.pullEventRaw -- These two lines prevent someone to stop your program using CTRL + T
  13. os.pullEvent = os.pullEventRaw
  14.  
  15. local door = "left" -- This is the side of your output to the door
  16. local jukebox = "right" -- This is the side where the disk drive used in guest function is attached to your computer
  17. local otme = 5 -- otme = opentime, it's the time the door is openned
  18. local ptme = 30 -- ptme = playtime, it's the time the computer plays the cd in the disk drive for the guest function
  19. local guest = "guest"
  20. local admin = "admin"
  21. local adminpswd = "your admin password" -- This is your Admin pswd you can change as you want
  22.  
  23. local pswdFile = fs.open("/data/pswd", "r")
  24. pswd = pswdFile:readLine()
  25. pswdFile.close()
  26.  
  27. --Instead of explain all the function, I'll let you try the program and understand by yourself ;)
  28.  
  29. while true do
  30.     term.clear()
  31.     term.setCursorPos(1,1)
  32.     term.setTextColor(colors.white)
  33.     print("Hello, please write the password :")
  34.     term.setTextColor(colors.lightGray)
  35.     print("(if you don't know it, write 'guest')")
  36.     term.setCursorPos(34,7)
  37.     term.setTextColor(colors.blue)
  38.     print("-KOD's Softs") -- This is just a copyright inside the program
  39.     term.setCursorPos(1,4)
  40.     term.setTextColor(colors.white)
  41.     local input = read("*")
  42.     if input == pswd then
  43.         term.clear()
  44.         term.setCursorPos(1,1)
  45.         term.setTextColor(colors.lime)
  46.         print("Welcome !")
  47.         term.setCursorPos(34,7)
  48.         term.setTextColor(colors.blue)
  49.         print("-KOD's Softs") -- This is just a copyright inside the program
  50.         rs.setOutput(door,true)
  51.         sleep(otme)
  52.         rs.setOutput(door,false)
  53.     elseif input == guest then
  54.         term.clear()
  55.         term.setCursorPos(1,1)
  56.         term.setTextColor(colors.orange)
  57.         print("Wait for someone to open the door")
  58.         term.setCursorPos(34,7)
  59.         term.setTextColor(colors.blue)
  60.         print("-KOD's Softs") -- This is just a copyright inside the program
  61.         disk.playAudio(jukebox)
  62.         sleep(ptme)
  63.         disk.stopAudio(jukebox)
  64.     elseif input == adminpswd then
  65.         term.clear()
  66.         term.setCursorPos(1,1)
  67.         term.setTextColor(colors.yellow)
  68.         print("Actiated with admin password")
  69.         rs.setOutput(door,true)
  70.         sleep(otme)
  71.         rs.setOutput(door,false)
  72.     elseif input == admin then
  73.         term.clear()
  74.         term.setCursorPos(1,1)
  75.         term.setTextColor(colors.yellow)
  76.         print("ADMIN MODE")
  77.         print("Enter admin password :")
  78.         term.setCursorPos(1,4)
  79.         local input = read("*")
  80.         if input == adminpswd then
  81.             term.clear()
  82.             term.setCursorPos(1,1)
  83.             term.setTextColor(colors.yellow)
  84.             print("Choose action")
  85.             term.setCursorPos(1,3)
  86.             print("1 - Close the program")
  87.             print("2 - Edit password")
  88.             term.setCursorPos(1,6)
  89.             local input = read()
  90.             if input == "1" then
  91.                 term.clear()
  92.                 term.setCursorPos(1,1)
  93.                 print("You closed the program")
  94.                 break
  95.             elseif input == "2" then
  96.                 term.clear()
  97.                 term.setCursorPos(1,1)
  98.                 term.setTextColor(colors.yellow)
  99.                 print("Enter new password")
  100.                 term.setCursorPos(1,3)
  101.                 local input = read()
  102.                 pswd = input
  103.                 local pswdFile = fs.open("/data/pswd", "w")
  104.                 pswdFile.write(input)
  105.                 pswdFile.close()
  106.             else
  107.                 term.clear()
  108.                 term.setCursorPos(1,1)
  109.                 term.setTextColor(colors.red)
  110.                 print("Wrong input")
  111.                 sleep(otme)
  112.             end
  113.         else
  114.             term.clear()
  115.             term.setCursorPos(1,1)
  116.             term.setTextColor(colors.red)
  117.             print("Wrong admin password")
  118.             sleep(otme)
  119.         end
  120.     else
  121.         term.clear()
  122.         term.setCursorPos(1,1)
  123.         term.setTextColor(colors.red)
  124.         print("Wrong password")
  125.         term.setCursorPos(34,7)
  126.         term.setTextColor(colors.blue)
  127.         print("-KOD's Softs") -- This is just a copyright inside the program
  128.         sleep(otme)
  129.     end
  130. end
Advertisement
Add Comment
Please, Sign In to add comment