Krastorio 2


An overhaul mod focusing on end-game technologies and moderately increased complexity.

Overhaul
7 months ago
0.18 - 1.1
338K
Transportation Logistics Trains Combat Armor Mining Fluids Logistic network Manufacturing Power Storage

b anti-crash-furnace workaround gets installed all the time

4 years ago
(updated 4 years ago)

I'm working on a command line lua script to extract the item database from Krastorio2. I noticed this workaround in prototypes/vanilla-changes/mandatory/entities-changes.lua:

-- Because Factorio won't start if not exist at least one prototype of assemblers and furnaces
if #data.raw.furnace == 0 then
local _, first_assembler = next(data.raw["assembling-machine"])
local furnace = krastorio_utils.tables.fullCopy(first_assembler)
furnace.type = "furnace"
furnace.name = "anti-crash-furnace"
/.../
data:extend({furnace})
end

The problem with it is that data.raw.furnace is an associative table, so #data.raw.furnace is always zero, regardless how many prototypes there are in it. In my case there are plenty, but this bug causes that anti-crash-furnace to still get added, which interferes with things (e.g. the use of next() there is non-deterministic in command line lua).

Using something like next(data.raw.furnace) == nil should work better.

This is Krastorio2 0.9.9.

Thanks!