function handleChestEvents(event) if event.msg.event == nil then handleChestGet_list(event) end if event.msg.event == "inject" then --handle inject event end end function handleChestGet_list(event) local itemName = "" local itemCount = 0 if mem.buttonState ~= 1 then return end if event.msg ~= nil then --for k, v in pairs(event.msg) do for i = #event.msg, 1, -1 do local v = event.msg[i] if v ~= nil and type(v) == "string" and v ~= "technic:uranium35_dustthen" then local spaceIndex = string.find(v, " ", 1, true) if spaceIndex ~= nil then itemName = string.sub(v, 1, spaceIndex -1) itemCount = string.sub(v, spaceIndex + 1) if tonumber(itemCount) >= 2 then digiline_send("injector", {name=itemName, count = 2, tags=itemName}) break end end end end end mem.itemName = itemName mem.itemCount = itemCount end function handleButtonEvents(event) if mem.buttonState == 0 then mem.buttonState = 1 digiline_send("uranbutton", "light_on") digiline_send("uranchest",{command="sort"}) digiline_send("uranchest",{command="get_list"}) else mem.buttonState = 0 digiline_send("uranbutton", "light_off") mem.outputCount = 0 end end function handleDetectorEvents(event) mem.outputCount = mem.outputCount + event.msg.count mem.totalProcessed = mem.totalProcessed + event.msg.count if mem.outputCount >= 2 then mem.outputCount = 0 local str = "Uran fissiletotal items\nprocessed:\n" .. tostring(mem.totalProcessed) .. "\n" .. "Fuels done\n" .. tostring(mem.fuelDone) .. "\n" digiline_send("uranmonitor", str) if mem.buttonState == 1 then digiline_send("uranchest",{command="sort"}) digiline_send("uranchest",{command="get_list"}) end end end function logDigilineEvents(event) local digilineEvents = {} if mem.digilineEvents ~= nil then digilineEvents = mem.digilineEvents end table.insert(digilineEvents, event) mem.digilineEvents = digilineEvents end if event.type == "program" then mem={} mem.buttonState = 0 mem.outputCount = 0 if mem.totalProcessed == nil then mem.totalProcessed = 0 end if mem.fuelDone == nill then mem.fuelDone = 0 end digiline_send("uranchest",{command="sort"}) digiline_send("uranbutton", "light_off") -- interrupt(1) end if event.type == "interrupt" then end if event.type == "digiline" then if event ~= nil then --logDigilineEvents(event) end if event.channel == "uranbutton" then handleButtonEvents(event) end if event.channel == "urandetector" then handleDetectorEvents(event) end if event.channel == "nuclearfueldetector" then mem.fuelDone = mem.fuelDone + 1 end if mem.buttonState ~= 1 then return end if (event.channel == "uranchest") then handleChestEvents(event) end end