Vehicle Deployer

by fgardt

Automate the deployment of your vehicles by using a vehicle deployer.

Content
a year ago
1.1
226
Transportation

b [FIXED] Crash while generating deployment recipes

1 year, 1 month ago

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
1 year, 1 month ago

Thanks for the extensive report! I‘ll see if I can implement your fix later today. If not please feel free to open a PR for it.

1 year, 1 month ago

should now be fixed with 1.0.7. Thanks again for reporting and going all the way and provide a fix aswell!

New response