Code: Select all
if entity.type == 'car' then
entity.surface.create_entity{
name = buffed_name,
position = entity.position,
quality = entity.quality,
force = entity.force_index,
snap_to_grid = false,
fast_replace = true,
spill = false,
raise_built = true,
orientation = entity.orientation,
-- grid = entity.grid,
-- trunk_inventory = entity.trunk_inventory,
-- enable_logistics_while_moving = entity.enable_logistics_while_moving,
-- ammo_inventory = entity.ammo_inventory,
-- request_filters = entity.request_filters, -- not needed cos the fast replace handles it
}
else
entity.surface.create_entity{
name = buffed_name,
position = entity.position,
direction = entity.direction,
quality = entity.quality,
force = entity.force_index,
snap_to_grid = false,
fast_replace = true,
spill = false,
raise_built = true,
}
endBelow are screenshots of the errors the game produces when the specified lines are uncommented
grid = entity.grid: trunk_inventory = entity.trunk_inventory: The other three lines produce basically the same error as the trunk_inventory line, so I'll skip them.
So, what's the problem here? Aside from the 'grid' error maybe suggesting that grid is a protected keyword or something similar, the other errors are basically saying "that data doesn't exist for this entity type", which is not the case.
I included the if statement at the start to demonstrate that the entity I'm replacing definitely is a 'car' type, and this screenshot below of the modding API page for surface.create_entity: From this we can see that, yes, 'car' type entities (which the Tank is) DO have those data structures. At least, I think they do. They definitely do have them as options that can be specified when being created. And the entity I am replacing for these tests has equipment grid items, and has inventory filters specified, so neither of those should be empty data fields.
But, maybe I dunno anything about anything (very possible). Maybe I'm completely confused and turned around, and maybe the errors I'm getting are totally logical and sound. Regardless, I am quite stumped as to why my code is breaking and could use some help.

