Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Load the required components
- local modem = peripheral.find("wired_modem") -- Wired modem peripheral
- local redstone = peripheral.find("redstone") -- Redstone peripheral
- -- Function to handle messages
- local function handleMessage()
- while true do
- local event, side, senderChannel, replyChannel, message, distance = os.pullEvent("modem_message")
- -- Check if the message is from computer_3
- if senderChannel == 3 then
- -- Check the message content
- if message == "ON" then
- -- Activate the redstone signal on the left side
- redstone.setOutput("left", true)
- print("Signal received: ON")
- sleep(5) -- Wait for 5 seconds
- redstone.setOutput("left", false) -- Deactivate the redstone signal after 5 seconds
- elseif message == "OFF" then
- -- Activate the redstone signal on the right side
- redstone.setOutput("right", true)
- print("Signal received: OFF")
- sleep(5) -- Wait for 5 seconds
- redstone.setOutput("right", false) -- Deactivate the redstone signal after 5 seconds
- end
- end
- end
- end
- -- Run the function to handle messages
- handleMessage()
Advertisement
Add Comment
Please, Sign In to add comment