I'm trying to read the energy status of multiple energy cells. I'm trying to make it adaptive so I just have to add more cells and add them to the network and the program recognizes them. Therefore I thought I use function which uses a loop to check for all the cells and add them to a table. Then returns the table. Unfortunately it seems the table is empty when I try to access it from the main program.
function prepare() cell = {} local peripheralList = peripheral.getNames() counter = 0 for Index = 1, #peripheralList do counter = counter + 1 if string.find(peripheralList[Index], "tile_thermalexpansion_cell") then cell[counter]=peripheral.wrap(peripheralList[Index]) end end return(cell) end function getEnergy() end cell = prepare() print(cell[1].getType())