-- reactor_sender.lua
-- Attach modem to "back" (or change side)
-- Attach adapter to reactor (e.g. "left")
local modemSide = "right"
local reactorSide = "back"
local channel = "reactorFuel"
local reactor = peripheral.wrap(reactorSide)
if not reactor then
error("No reactor peripheral found on " .. reactorSide)
end
rednet.open(modemSide)
local function getFuelLevel()
local inv = reactor.list()
local total = 0
local max = 7 * 4 -- 7 quad cells = 28 units
for _, item in pairs(inv) do
if item.name:find("uranium_fuel_rod") and not item.name:find("depleted") then
if item.name:find("quad") then
total = total + 4
elseif item.name:find("dual") then
total = total + 2
else
total = total + 1
end
end
end
return total / max
end
while true do
local fuel = getFuelLevel()
rednet.broadcast(fuel, channel)
sleep(5) -- adjust update interval
end