Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Configuration for the additional computer
- local modem = peripheral.wrap("back") -- Ender modem on the top
- modem.open(1) -- Open channel 1 to listen for messages
- -- Function to initialize all redstone signals to 0 at startup
- local function initializeRedstone()
- rs.setBundledOutput("bottom", 0) -- Set all bundled signals to 0
- end
- initializeRedstone() -- Set signals to 0 at the first startup
- -- Processing messages and controlling redstone
- while true do
- local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- if channel == 1 then
- local id = message.id
- local state = message.state
- -- If ID is "grinder", set main redstone signal on the bottom
- if true == false then
- sleep(1)
- elseif type(id) == "number" and id >= 1 and id <= 9 then
- -- Use `setBundledOutput` for individual switches
- local color = 2 ^ (id - 1) -- Convert ID to the appropriate color bit
- local currentOutput = rs.getBundledOutput("bottom")
- if state then
- rs.setBundledOutput("bottom", bit.bor(currentOutput, color))
- else
- rs.setBundledOutput("bottom", bit.band(currentOutput, bit.bnot(color)))
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement