I've got this crash:
3.569 Error ModManager.cpp:1625: Failed to load mod "vehicle-deployer": __vehicle-deployer__/prototypes/vehicle-recipes.lua:41: attempt to concatenate field 'name' (a nil value)
stack traceback:
__vehicle-deployer__/prototypes/vehicle-recipes.lua:41: in main chunk
[C]: in function 'require'
__vehicle-deployer__/data-final-fixes.lua:1: in main chunk
The line producing the crash is this:
name = "VD_vehicle-deploy-" .. name .. "-" .. item.name,
The immediate cause of the crash is that item.name doesn't exist. The root of this is the way you get items when vehicle.placeable_by is set (lines 23f.):
if vehicle.placeable_by then
items = vehicle.placeable_by
This will break for two reasons:
- vehicle.placeable_by can be either a single item or an array of items,
- each item is defined as
{ item = String, count = uint32 }
Replacing lines 23-24 with the following will fix the bug:
if vehicle.placeable_by then
-- vehicle.placeable_by is a single ItemToPlace: {item = String, count = uint32}
if vehicle.placeable_by.item then
-- We need item.name later on!
items = { {name = vehicle.placeable_by.item} }
-- vehicle.placeable_by is an array of ItemToPlace: { {item = String, count = uint32}, ... }
else
for _, i in pairs(vehicle.placeable_by) do
table.insert(items, {name = i.item})
end
end