Even Distribution


Modifies CTRL + Click Drag to evenly distribute the items over multiple buildings. Also adds Inventory Cleanup hotkey (SHIFT+C) which evenly distributes unneeded items from inventory into nearby machines.

Utilities
5 months ago
0.15 - 2.1
534K

g Crash on Factorio 2.1 - fuel_category was renamed to fuel_categories

a month ago

Factorio 2.1 renamed the prototype field fuel_category (string)
to fuel_categories (array). Reading the old key now throws
instead of returning nil.

Error in game:
LuaItemPrototype doesn't contain key fuel_category

The mod still uses fuel_category in 6 places:

scripts/setup.lua:49
:groupBy(function(k,v) return v.fuel_category end)

scripts/setup.lua:297
if not defaultTrash[name] and item.fuel_category then

scripts/helpers.lua:63
if prototype.fuel_category then ...

scripts/cleanup.lua:267
entity.burner.fuel_inventory.get_item_count(
item.name) > 0 and prototype.fuel_category

scripts/drag.lua:315
(same pattern as cleanup.lua)

scripts/helpers/LuaControl.lua:169
storage.fuelList[prototype.fuel_category]

Suggested fix:
local fc = prototype.fuel_categories
if fc == nil or fc[1] == nil then return nil end
local category = fc[1]

Tested on: Factorio 2.1.24 (build 87808), space-age, ~240 mods.
Works after applying the above change, so this is the only blocker.

a month ago

+1

The mod Even Distribution (2.1.0) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event even-distribution::on_init()
LuaItemPrototype doesn't contain key fuel_category.
stack traceback:
[C]: in function 'index'
__even-distribution
/scripts/setup.lua:297: in function 'generateTrashItemList'
even-distribution/scripts/setup.lua:16: in function 'func'
even-distribution/framework.lua:49: in function 'handleEvent'
even-distribution/framework.lua:58: in function <even-distribution/framework.lua:58>

a month ago

Error while running event even-distribution::on_init()
LuaItemPrototype doesn't contain key fuel_category.
stack traceback:
[C]: in function 'index'
__even-distribution
/scripts/setup.lua:297: in function 'generateTrashItemList'
even-distribution/scripts/setup.lua:16: in function 'func'
even-distribution/framework.lua:49: in function 'handleEvent'
even-distribution/framework.lua:58: in function <even-distribution/framework.lua:58>

a month ago

+1

Error while running event even-distribution::on_configuration_changed
LuaItemPrototype doesn't contain key fuel_category.
stack traceback:
[C]: in function 'index'
__even-distribution
/scripts/setup.lua:297: in function 'generateTrashItemList'
even-distribution/scripts/setup.lua:16: in function 'func'
even-distribution/framework.lua:49: in function 'handleEvent'
even-distribution/framework.lua:58: in function <even-distribution/framework.lua:58>

a month ago

Can confirm.

a month ago

+1

a month ago

+1
same error msg as everyone else

a month ago

1+

Die Mod Even Distribution (2.1.0) hat einen Fehler verursacht, der nicht behoben werden kann.
Bitte informiere den Autor der Mod über diesen Fehler.

Error while running event even-distribution::on_init()
LuaItemPrototype doesn't contain key fuel_category.
stack traceback:
[C]: in function 'index'
__even-distribution
/scripts/setup.lua:297: in function 'generateTrashItemList'
even-distribution/scripts/setup.lua:16: in function 'func'
even-distribution/framework.lua:49: in function 'handleEvent'
even-distribution/framework.lua:58: in function <even-distribution/framework.lua:58>

a month ago

Factorio 2.1 renamed the prototype field fuel_category (string)
to fuel_categories (array). Reading the old key now throws
instead of returning nil.

Error in game:
LuaItemPrototype doesn't contain key fuel_category

The mod still uses fuel_category in 6 places:

scripts/setup.lua:49
:groupBy(function(k,v) return v.fuel_category end)

scripts/setup.lua:297
if not defaultTrash[name] and item.fuel_category then

scripts/helpers.lua:63
if prototype.fuel_category then ...

scripts/cleanup.lua:267
entity.burner.fuel_inventory.get_item_count(
item.name) > 0 and prototype.fuel_category

scripts/drag.lua:315
(same pattern as cleanup.lua)

scripts/helpers/LuaControl.lua:169
storage.fuelList[prototype.fuel_category]

Suggested fix:
local fc = prototype.fuel_categories
if fc == nil or fc[1] == nil then return nil end
local category = fc[1]

Tested on: Factorio 2.1.24 (build 87808), space-age, ~240 mods.
Works after applying the above change, so this is the only blocker.

Can you let us please know where to place this fix (in which file) so we to may benefit. Thank You.

a month ago

Factorio 2.1 renamed the prototype field fuel_category (string)
to fuel_categories (array). Reading the old key now throws
instead of returning nil.

Error in game:
LuaItemPrototype doesn't contain key fuel_category

The mod still uses fuel_category in 6 places:

scripts/setup.lua:49
:groupBy(function(k,v) return v.fuel_category end)

scripts/setup.lua:297
if not defaultTrash[name] and item.fuel_category then

scripts/helpers.lua:63
if prototype.fuel_category then ...

scripts/cleanup.lua:267
entity.burner.fuel_inventory.get_item_count(
item.name) > 0 and prototype.fuel_category

scripts/drag.lua:315
(same pattern as cleanup.lua)

scripts/helpers/LuaControl.lua:169
storage.fuelList[prototype.fuel_category]

Suggested fix:
local fc = prototype.fuel_categories
if fc == nil or fc[1] == nil then return nil end
local category = fc[1]

Tested on: Factorio 2.1.24 (build 87808), space-age, ~240 mods.
Works after applying the above change, so this is the only blocker.

While simply renaming it prevents the crash, it can interfere with fuel distribution using Ctrl + Drag and Shift + C.

a month ago

My log of crash

O mod Even Distribution (2.1.0) causou um erro não recuperável.
Por favor, reporte este erro ao autor do mod.

Error while running event even-distribution::on_init()
LuaItemPrototype doesn't contain key fuel_category.
stack traceback:
[C]: in function 'index'
__even-distribution
/scripts/setup.lua:297: in function 'generateTrashItemList'
even-distribution/scripts/setup.lua:16: in function 'func'
even-distribution/framework.lua:49: in function 'handleEvent'
even-distribution/framework.lua:58: in function <even-distribution/framework.lua:58>

a month ago

Just switched to stable 2.1.24 and hoped this is solved, but same "fuel_category" crash

a month ago

Yeah love that you took the time to update since I LOVE this mod sucks about the bug.
The mod Even Distribution (2.1.0) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event even-distribution::on_init()
LuaItemPrototype doesn't contain key fuel_category.
stack traceback:
[C]: in function 'index'
__even-distribution
/scripts/setup.lua:297: in function 'generateTrashItemList'
even-distribution/scripts/setup.lua:16: in function 'func'
even-distribution/framework.lua:49: in function 'handleEvent'
even-distribution/framework.lua:58: in function <even-distribution/framework.lua:58>

a month ago

Hello everyone, for as long as the author is away I'm maintaining the fork of this Mod, for all those that want to keep using this mod.
I try my best to keep up with the changes and resolve some ancient issues aswell.

https://mods.factorio.com/mod/even-distribution-fork

4 days ago

+1, same crash on 2.1.25 (setup.lua:297 in on_configuration_changed, so saves won't load at all). I patched the 6 call sites locally and it's been fine: each item takes its first fuel category, which is the only one for vanilla and nearly every modded fuel.

  • setup.lua groupBy: :groupBy(function(__,p) return p.fuel_categories and p.fuel_categories[1] end)
  • setup.lua:297: item.fuel_category -> item.fuel_categories
  • helpers.lua:63: fuel_category ~= nil -> fuel_categories ~= nil (both halves)
  • helpers/LuaControl.lua:169: storage.fuelList[prototype.fuel_categories and prototype.fuel_categories[1] or ""] or {}
  • cleanup.lua:267 and drag.lua:315: entity.burner.fuel_categories[(prototype.fuel_categories or {})[1] or ""]

Tested headless on 2.1.25: 2.1.0 crashes on a new map, the patched build runs clean, and my modded save loads past it. Happy to send a PR if the repo is taking them.

New response