Hi! Got this:
Failed to load mods: __core__/lualib/dataloader.lua:23: Invalid array of prototypes:
{}
stack traceback:
[C]: in function 'error'
__core__/lualib/dataloader.lua:23: in function 'extend'
__Velora__/prototypes/rail-maker-recipes.lua:179: in main chunk
[C]: in function 'require'
__Velora__/data-final-fixes.lua:51: in main chunk
I inserted a few debug loggings, and, with the help of AI, I believe it's due to a combination with https://mods.factorio.com/mod/scrap-chemistry.
Let's look at the recipe casting-iron.
{
...
ingredients = {
{
amount = 20,
fluidbox_multiplier = 10,
name = "molten-iron",
type = "fluid"
}
},
...
name = "casting-iron",
...
order = "b[casting]-a[casting-iron]",
results = {
{
always_fresh = true,
amount = 2,
name = "hot-iron-plate",
shared_probability = {
max = 0.99000000000000004,
min = 0
},
si_modified = true,
type = "item"
},
{
amount = 1,
ignored_by_productivity = 1,
name = "tar",
shared_probability = {
max = 1,
min = 0.9
},
show_details_in_recipe_tooltip = false,
si_modified = true,
type = "item"
}
},
...
}
Scrappy Chemistry inserts a property si_modified = true for all results it touched, so that's the smoking gun to link to their mod
- but critically, the recipe now has TWO results
then, in your rail-maker-recipes.lua:
- replacements contains only keys carminite-gear, carminite-plate, and carminite-rod, nothing else
- that's because all other recipes, including our observed casting-iron, have not one, but two results, thus failing the your check of ... and #recipe.results == 1 ...
- Scrappy Chemistry knows nothing about carminite, thus they don't add scrap, thus their recipes' results array still has contains just one result and those keys end up in replacements
- thus, for casting-iron and the other recipes modified by Scrappy Chemistry, your converted in local function make_casting_recipe is never true
- therefore, for those recipes, your alternative is always nil, since in make_casting_recipe, this is executed always: if not converted then return end
- and thus, for those recipes, your generated always remains {}, which apparently Factorio's data.extend doesn't like, won't continue silently which would have been nice, but throws an error (... if #otherdata == 0 then ... error(...) ...)
as a concrete example, the first recipe in your recipes, for me, is acceleration-cargo-wagon, with a product of acceleration-cargo-wagon
- (because data.raw["cargo-wagon"]["acceleration-cargo-wagon"] exists, thus ends up in your supported_items, thus ends up in your recipes)
- acceleration-cargo-wagon's ingredients are cargo-wagon, acceleration-chest, and chromium-ingot, each of type item
- but none of them are in your replacements, and crucially, cargo-wagon isn't, too, because its recipe has two results as discussed above
- so your local replacement = ingredient.type == "item" and replacements[ingredient.name] is never true, thus your converted is never true, thus your alternative is always nil
This is true for everything in your recipes array. I don't know about the carminite business, but apparently, in your supported_items, there is no item named like carminite, so they don't add an alternative to your generated, too.
Soooo... That's the technical reason, but I don't have any idea what's going on here or what your intention with rail-maker-recipes.lua is, I just started a new save. I don't know whether you would want to add alternatives even though a recipe has two results, but it seems to me that your code technically allows for generated being just {} because there's no guarantee that an alternative is ever created. You would probably have to at least insert some if #generated > 0 then data:extend(generated) end. I did this and Factorio starts without a crash - that's fine for me now, but that's maybe just a quick hack and you would have to do something more involved, I don't know.
Thanks for your modding work! :-)