This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
jjjhfam's profile picture

How To Wrap Multiple Peripherals of the Same Type

Started by jjjhfam, 05 July 2015 - 07:50 PM
jjjhfam #1
Posted 05 July 2015 - 09:50 PM
I'm trying to set up multiple Big Reactors and have them controlled by a single computer. How would I wrap all of the Big Reactors connected to the network? I already understand the Big Reactors API.
TheOddByte #2
Posted 05 July 2015 - 10:15 PM
Well if you know the type and you know how to use tables you could do something like this

local reactors = {}
for _, name in ipairs( peripheral.getNames() ) do
    if peripheral.getType( name ) == "reactor" then
        reactors[i] = peripheral.wrap( name )
    end
end
Or in later versions of ComputerCraft

local reactors = { peripheral.find( "reactor" ) }
I don't really know if the type of Big Reactors reactors is reactor, so you should change that if it's incorrect.