SHOW:
|
|
- or go back to the newest paste.
| 1 | - | -- Script A: On redstone change, broadcast ACTIVATE/DEACTIVATE |
| 1 | + | -- Script B: Listen for "pulse" broadcasts and drive front-side redstone |
| 2 | ||
| 3 | -- 1) Open your wireless modem on the top side | |
| 4 | - | rednet.open("top") -- Open Rednet on "top" :contentReference[oaicite:2]{index=2}
|
| 4 | + | rednet.open("top") -- Open Rednet on "top" :contentReference[oaicite:7]{index=7}
|
| 5 | ||
| 6 | - | -- 2) Loop, waiting for any redstone input change |
| 6 | + | -- 2) Loop, receiving commands and setting the front output |
| 7 | while true do | |
| 8 | - | os.pullEvent("redstone") -- Wait for redstone event :contentReference[oaicite:3]{index=3}
|
| 8 | + | local senderID, message = rednet.receive("pulse") -- Receive on protocol "pulse" :contentReference[oaicite:8]{index=8}
|
| 9 | ||
| 10 | - | -- 3) Read the back-side redstone input |
| 10 | + | -- 3) Update front-side redstone based on the message |
| 11 | - | if redstone.getInput("front") then -- Get back-side input (boolean) :contentReference[oaicite:4]{index=4}
|
| 11 | + | if message == "ACTIVATE" then |
| 12 | - | rednet.broadcast("ACTIVATE", "pulse") -- Broadcast activation on protocol "pulse" :contentReference[oaicite:5]{index=5}
|
| 12 | + | redstone.setOutput("front", true) -- Turn on front redstone :contentReference[oaicite:9]{index=9}
|
| 13 | - | else |
| 13 | + | elseif message == "DEACTIVATE" then |
| 14 | - | rednet.broadcast("DEACTIVATE", "pulse") -- Broadcast deactivation on protocol "pulse" :contentReference[oaicite:6]{index=6}
|
| 14 | + | redstone.setOutput("front", false) -- Turn off front redstone :contentReference[oaicite:10]{index=10}
|
| 15 | end | |
| 16 | end | |
| 17 |