Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- cpass = {}
- mon = peripheral.wrap("left")
- function boot()
- clear()
- if fs.exists("pass") then
- term.redirect(mon)
- print("Loading...")
- --find perphs
- piston = "right"
- note = "back"
- light = "top"
- mon = peripheral.wrap("left")
- reader = peripheral.wrap("front")
- clear()
- textutils.slowPrint("PVault Loaded!")
- sleep(math.random(1,5))
- clear()
- passwordFile = fs.open("pass","r")
- password = passwordFile.readLine()
- passwordFile.close()
- main()
- else
- print("Welcome and thank you for purchasing PVault!")
- sleep(3)
- clear()
- print("Before we begin, check to make sure your peripherals are in place correctly:")
- print("Piston(redstone w/negate)=right, light=top, card reader=front, monitor=left, and alarm(noteblock)=back")
- print("When this is done, please press Y.")
- while true do
- local event, param1=os.pullEvent("char")
- if param1 == "y" then
- clear()
- print("Please take a blank mag card and swipe it now. Do not lose this! This will be your only access to the vault.")
- reader = peripheral.wrap("front")
- reader.setInsertCardLight(true)
- while true do
- password = math.random(11111,99999)
- reader.beginWrite(password,"Vault Key")
- event,x,y,z = os.pullEvent("mag_swipe")
- reader.setInsertCardLight(false)
- piston = "right"
- note = "back"
- light = "top"
- file = fs.open("pass","w")
- file.write(password)
- file.close()
- clear()
- term.setTextColor(colors.lime)
- print("Vault key created!")
- sleep(3)
- clear()
- print("Setup complete! Restarting program...")
- sleep(3)
- clear()
- term.setTextColor(colors.white)
- reader.cancelWrite()
- boot()
- end
- end
- end
- end
- end
- function main()
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- print("Please swipe card...")
- reader.setInsertCardLight(true)
- while true do
- event,x,y,z = os.pullEvent("mag_swipe")
- passwordFile = fs.open("pass","r")
- password = tonumber(passwordFile.readLine())
- passwordFile.close()
- reader.setInsertCardLight(false)
- if param1 == password then
- term.setTextColor(colors.lime)
- textutils.slowPrint("Card accepted!")
- sleep(2)
- clear()
- timer=10 --change this for the amount of time you want the vault open in seconds
- redstone.setOutput(piston, true)
- for i=1, timer do
- print("Door open for "..tostring(timer).." seconds...")
- timer = timer - 1
- sleep(1)
- clear()
- end
- clear()
- term.setTextColor(colors.red)
- redstone.setOutput(piston,false)
- print("Door sealed!")
- sleep(2)
- clear()
- timer = 120 --change this for the amount of time you want the vault time locked after a recent opening in seconds. Default=2 minutes
- for i=1, timer do
- print("Time lock activated! Door will be active again in "..tostring(timer).." seconds.")
- timer = timer - 1
- sleep(1)
- clear()
- end
- clear()
- term.setTextColor(colors.white)
- main()
- else
- term.setTextColor(colors.red)
- timer = 120 --change this for the amount of time you want the vault to be locked and the alarm to be set off after failing with card. Default 2 minutes
- print("Invalid card! Initiating lock-down procedures!")
- for i=1, (timer * 2) do
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.black)
- redstone.setOutput(note, true)
- redstone.setOutput(light, true)
- sleep(.25)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.red)
- redstone.setOutput(note,false)
- redstone.setOutput(light,false)
- timer = timer - 1
- sleep(.25)
- end
- clear()
- term.setTextColor(colors.white)
- main()
- end
- end
- end
- boot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement