Opus 5.5 response:
Root cause and full fix for 2.1.20 (fuel_category → fuel_categories)
Following up on Frank_ACE and MechBFP: a straight rename stops the crash, but CTRL+drag then does nothing for fuel. In 2.1.20 the new field has a different shape depending on the object:
LuaItemPrototype.fuel_categories is array[string]?, e.g. {"chemical"}. It is nil when the item isn't a fuel.
LuaBurner.fuel_categories is dictionary[string → true], e.g. {chemical = true}.
So entity.burner.fuel_categories[prototype.fuel_categories] never matches. Looping over the item's categories with pairs() doesn't match either, because it yields the indices 1, 2, … rather than the category names.
Six places need changing:
-
scripts/helpers.lua:63 (the "fuel" condition): a plain rename is enough here, since it only checks for nil.
["fuel"] = function(obj) return obj.object_name == "LuaItemStack" and obj.prototype.fuel_categories ~= nil or obj.fuel_categories ~= nil end,
-
scripts/setup.lua:297 (generateTrashItemList, the crash in this thread): a plain rename.
if item.fuel_categories and not defaultTrash[name] then
-
scripts/setup.lua:49 (the fuel upgrade list): groupBy("fuel_category") can't be a string key any more. The helper calls a function key as key(k, v), and after :toArray() the k is a number, so the item is the second argument:
:groupBy(function(__, item)
return item.fuel_categories and item.fuel_categories[1]
end)
-
scripts/drag.lua:315 (why CTRL+drag stops working):
elseif entity.burner and prototype.fuel_categories and (function()
for __,category in ipairs(prototype.fuel_categories) do
if entity.burner.fuel_categories[category] then return true end
end
return false
end)() then
-
scripts/cleanup.lua:267 (SHIFT+C): the same pattern.
local burnerAccepts = false
if entity.burner and prototype.fuel_categories then
for __,category in ipairs(prototype.fuel_categories) do
if entity.burner.fuel_categories[category] then burnerAccepts = true break end
end
end
if burnerAccepts and entity:inventory("fuel").can_insert(item) then
-
scripts/helpers/LuaControl.lua:169 (replacing lower-tier fuel): this is easy to miss. It doesn't crash on load, only the first time the mod tries to swap out lower-tier fuel.
for __,inferiorFuel in pairs(storage.fuelList[prototype.fuel_categories[1]] or {}) do
Notes:
Items with more than one fuel category go into the upgrade list under their first category only. That matches the old behaviour, where each item had exactly one category.
If you unzip the mod to patch it, rezip it with the top-level even-distribution_2.1.0/ folder inside. Also rename or remove the original zip: if both are in the mods folder, Factorio keeps loading the original zip and your patched copy is ignored.
API references: LuaItemPrototype::fuel_categories, LuaBurner::fuel_categories