Advertisement
BookerTheGeek

Untitled

Feb 25th, 2025 (edited)
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Configuration for the additional computer
  2. local modem = peripheral.wrap("back") -- Ender modem on the top
  3. modem.open(1) -- Open channel 1 to listen for messages
  4.  
  5. -- Function to initialize all redstone signals to 0 at startup
  6. local function initializeRedstone()
  7.     rs.setBundledOutput("bottom", 0) -- Set all bundled signals to 0
  8. end
  9.  
  10. initializeRedstone() -- Set signals to 0 at the first startup
  11.  
  12. -- Processing messages and controlling redstone
  13. while true do
  14.     local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  15.     if channel == 1 then
  16.         local id = message.id
  17.         local state = message.state
  18.            
  19.          -- If ID is "grinder", set main redstone signal on the bottom
  20.          if true == false then
  21.             sleep(1)
  22.         elseif type(id) == "number" and id >= 1 and id <= 9 then
  23.             -- Use `setBundledOutput` for individual switches
  24.             local color = 2 ^ (id - 1) -- Convert ID to the appropriate color bit
  25.             local currentOutput = rs.getBundledOutput("bottom")
  26.             if state then
  27.                 rs.setBundledOutput("bottom", bit.bor(currentOutput, color))
  28.             else
  29.                 rs.setBundledOutput("bottom", bit.band(currentOutput, bit.bnot(color)))
  30.             end
  31.         end
  32.     end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement