Please check all cycles and local variables across the code.
Please see comments below
if core ~= nil then
local elementsIdList = core.getElementIdList()
for _,id in pairs(elementsIdList) do -- use ipairs instead
local elementType = core.getElementTypeById(id):lower()
if elementType:find("container") then
name = core.getElementNameById(id) -- should be local
if string.match(name, "CH_") or string.match(name, "C_") then
temp = split(name, "_") -- should be local
table.insert(containersIdList , {id, temp[1], string.match(temp[2], "%d+"), string.sub(temp[2], -1), temp[3], hasValue(temp[4])})
--1: id, 2: type, 3: containercount, 4: containersize, 5: material, 6: description
end
end
end
end
local function getColor(number)
if number < 50 then
return "rgb(255," .. utils.round(utils.map(number, 0, 40, 100, 255)) .. ",0)"
else
return "rgb(" .. utils.round(utils.map(number, 40, 100, 255, 155)) .. ",255,0)"
end
end
This code cannot work with different containers in one hub.
Please consider specifying the volume/capacity in the name of the hub.