dynamicXblue

CC Mek Reactor On/Off

Aug 16th, 2025 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.68 KB | None | 0 0
  1. local monitor = peripheral.find("monitor")
  2. local modem = peripheral.find("modem") or error("No modem attached", 0)
  3. local status = -1 -- -1 - null 0 - Off 1 - On
  4.  
  5. modem.open(1)
  6.  
  7. while true do
  8.     local event, side, channel, replyChannel, message, distance
  9.     repeat
  10.         event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  11.     until channel == 1
  12.  
  13.     if status == -1 or (message < 0.5 and status == 0) then
  14.         redstone.setOutput("back", true) -- Redstone on
  15.         status = 1
  16.         print("Reactor On")
  17.     elseif status == -1 or (message > 0.8 and status == 1) then
  18.         redstone.setOutput("back", false) -- Redstone off
  19.         status = 0
  20.         print("Reactor Off")
  21.     end
  22.    
  23. end
Advertisement
Add Comment
Please, Sign In to add comment