Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sensorSide = "side_of_sensor" -- Replace with the side the sensor is connected to
- local keycardSide = "side_of_keycard_reader" -- Replace with the side the keycard reader is connected to
- local speakerSide = "side_of_speaker" -- Replace with the side the speaker is connected to
- local monitorSide = "side_of_monitor" -- Replace with the side the monitor is connected to
- local sensor = peripheral.wrap(sensorSide)
- local keycard = peripheral.wrap(keycardSide)
- local speaker = peripheral.wrap(speakerSide)
- local monitor = peripheral.wrap(monitorSide)
- local authorizedCards = {"CardID1", "CardID2"} -- Add authorized card IDs
- local function activateAlarm()
- speaker.playSound("entity.enderman.stare", 1.0, 1.0) -- Adjust sound as needed
- monitor.clear()
- monitor.setTextColor(colors.red)
- monitor.setCursorPos(1, 1)
- monitor.write("INTRUDER ALERT!")
- -- Add more actions like notifying via chat or sending a redstone signal
- end
- while true do
- local event, side, xPos, yPos, player = os.pullEvent()
- if event == "keypad" and side == keycardSide then
- for _, id in ipairs(authorizedCards) do
- if player == id then
- print("Access granted for " .. player)
- break -- Authorized card detected, no need to check further
- else
- print("Unauthorized access attempt by " .. player)
- activateAlarm()
- end
- end
- elseif event == "motion" and side == sensorSide then
- print("Motion detected!")
- activateAlarm()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement