Guest User

Gate

a guest
Oct 3rd, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. -- Configuration
  2. -- Strings
  3. -- Passwords
  4. local sBypasspw = "bypass"
  5. local sDoorpw = "door"
  6. local sRedstoneSide = "back"
  7. local sAlarmSide = "left"
  8. local sMasterpw = "master"
  9. local sAlarmInput = ""
  10. local sTeslaSide = "bottom"
  11. local sTesla = "yes"
  12. -- Names
  13. local sVillageName = "derpington"
  14.  
  15. -- Values
  16. -- Door values
  17. local tDoor = 5
  18. local tBypass = 15
  19. local nWrongTimes = 3
  20. local nWrongCount = 0
  21.  
  22. -- Do not edit from here
  23.  
  24. -- Functions
  25.  
  26. function clearPrint(string, x, y)
  27.   if not x or x < 0 then x = 1 end
  28.   if not y or y < 0 then y = 1 end
  29.   term.clear()
  30.   term.setCursorPos(x,y)
  31.   print(string)
  32. end
  33.  
  34. -- if statement
  35.  
  36. function checkPW(PW)
  37.     if PW == sDoorpw then
  38.         clearPrint("Password correct! Please proceed - door will close in "..tDoor.." seconds.")
  39.         rs.setOutput(sRedstoneSide,false)
  40.         sleep(tDoor)
  41.         rs.setOutput(sRedstoneSide,true)
  42.         clearPrint("Door closed!")
  43.         sleep(1.5)
  44.     elseif PW == sBypasspw then
  45.         clearPrint("System Bypassed. Gate will remain open for "..tBypass.." seconds. Please proceed.")
  46.         rs.setOutput(sRedstoneSide,false)
  47.         sleep(tBypass)
  48.         rs.setOutput(sRedstoneSide,true)
  49.         clearPrint("Door closed!")
  50.         sleep(1.5)
  51.     else
  52.         clearPrint("Password incorrect! Please try again")
  53.         sleep(1)
  54.         nWrongCount = nWrongCount + 1
  55.         if nWrongCount == nWrongTimes then
  56.           if sTesla == "yes" then
  57.             rs.setOutput(sAlarmSide,true)
  58.             clearPrint("Alarms Activated!")
  59.             sleep(1.8)
  60.             rs.setOutput(sTeslaSide,true)
  61.             clearPrint("HAHA DIE BITCH!")
  62.             sleep(3)
  63.             rs.setOutput(sAlarmSide,false)
  64.             rs.setOutput(sTeslaSide,false)
  65.             nWrongCount = 0 -- resets wrong count
  66.           else
  67.             while sAlarmInput ~= sMasterpw do
  68.                 rs.setOutput(sAlarmSide,true) -- activates alarm
  69.                     clearPrint("Alarms activated! Please enter Master password to de-activate alarms.")
  70.                     write("Master password: ")
  71.                     sAlarmInput = read()
  72.             end
  73.             clearPrint("De-activated alarms...")
  74.             sleep(1)
  75.             nWrongCount = 0 -- resets wrong count
  76.             sAlarmInput = ""
  77.             rs.setOutput(sAlarmSide,false) -- deactivates alarm
  78.           end
  79.         nWrongCount = 0
  80.         end -- end if function for wrong times
  81.     end
  82. end
  83.  
  84.  
  85. while true do
  86.     clearPrint("Welcome to "..sVillageName..", user.")
  87.     write("Enter password to open gate: ")
  88.     rs.setOutput(sRedstoneSide,true)
  89.     if checkPW(read()) == sBypasspw then break end
  90. end
Advertisement
Add Comment
Please, Sign In to add comment