@Omnifarious - I think I found a bug that has been haunting the game for a while. I'll call it the GHOST bug :)
It crashes on the last line in dropItems:
entity.surface.spill_item_stack(entity.position, {name = name, count = count}, false, entity.force, false)
stating invalid entity.
Inside this if statement:
if count > 0 then
-- now we're forced to spill items
entity = entity or global.forces[player.force.name].roboport
-- log("Spilling items for: ".. entity.name .. "for count: ".. count .. "player force: ".. player.force.name)
entity.surface.spill_item_stack(entity.position, {name = name, count = count}, false, entity.force, false)
end
Error while running event level::on_player_main_inventory_changed (ID 34)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
[C]: in function '__index'
...oaming/Factorio/game1/temp/currently-playing/control.lua:650: in function 'dropItems'
...oaming/Factorio/game1/temp/currently-playing/control.lua:613: in function <...oaming/Factorio/game1/temp/currently-playing/control.lua:552>
5621.000 Error ServerMultiplayerManager.cpp:92: MultiplayerManager failed: "The scenario level caused a non-recoverable error.
Please report this error to the scenario author.
Error while running event level::on_player_main_inventory_changed (ID 34)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
[C]: in function '__index'
...oaming/Factorio/game1/temp/currently-playing/control.lua:650: in function 'dropItems'
...oaming/Factorio/game1/temp/currently-playing/control.lua:613: in function <...oaming/Factorio/game1/temp/currently-playing/control.lua:552>"
I reproduced multiple crashes, if I did find this - it is only an issue using ghost images, which brave new world uses quite a bit.
It runs dropItems when the entity that is dropping is an "entity-ghost". I changed the last if block to this and it has hit it in the failure case, but has not crashed:
if count > 0 then
-- now we're forced to spill items
entity = entity or global.forces[player.force.name].roboport
if (entity.name == "entity-ghost") then
log("WOULD HAVE CRASHED !")
else
entity.surface.spill_item_stack(entity.position, {name = name, count = count}, false, entity.force, false)
end
end
Let me know if you have a better solution. This tends to take many hours of gameplay before it shows up. When it does, it crashes pretty frequently.