Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Combination Lock Script with Redstone Signal
- local correctPasscode = "5432"
- local userPasscode = ""
- -- Function to clear the screen
- local function clearScreen()
- term.clear()
- term.setCursorPos(1, 1)
- end
- -- Function to prompt user for input
- local function prompt(message)
- clearScreen()
- print(message)
- end
- -- Function to handle passcode input
- local function getInput()
- prompt("Enter passcode:")
- userPasscode = read()
- end
- -- Function to send redstone signal
- local function sendRedstoneSignal(duration)
- rs.setOutput("left", true) -- Send a redstone signal
- sleep(duration) -- Wait for the specified duration
- rs.setOutput("left", false) -- Turn off the redstone signal
- end
- -- Main program
- while true do
- getInput()
- if userPasscode == correctPasscode then
- prompt("Access Granted!")
- sendRedstoneSignal(3)
- sleep(2)
- else
- prompt("Incorrect passcode! Try again.")
- sleep(2) -- Wait for 2 seconds before clearing the screen
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement