jaklsfjlsak

红石信号发射

Apr 21st, 2025 (edited)
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. -- Script A: On redstone change, broadcast ACTIVATE/DEACTIVATE
  2.  
  3. -- 1) Open your wireless modem on the top side
  4. rednet.open("top")                            -- Open Rednet on "top" :contentReference[oaicite:2]{index=2}
  5.  
  6. -- 2) Loop, waiting for any redstone input change
  7. while true do
  8.   os.pullEvent("redstone")                    -- Wait for redstone event :contentReference[oaicite:3]{index=3}
  9.  
  10.   -- 3) Read the back-side redstone input
  11.   if redstone.getInput("front") then           -- Get back-side input (boolean) :contentReference[oaicite:4]{index=4}
  12.     rednet.broadcast("ACTIVATE", "pulse")     -- Broadcast activation on protocol "pulse" :contentReference[oaicite:5]{index=5}
  13.   else
  14.     rednet.broadcast("DEACTIVATE", "pulse")   -- Broadcast deactivation on protocol "pulse" :contentReference[oaicite:6]{index=6}
  15.   end
  16. end
  17.  
Advertisement
Add Comment
Please, Sign In to add comment