Running the 0.0.3 version of the mod in multiplayer and attempting to place a "Floor-O-Matic" causes a script error and closes Factorio. The error is:
"Error while running the event handler: _ _ floors _ _\control.lua:254: Map doesn't contain 1 player, this function can't be used"
The code it's referring to is this:
Code: Select all
function safe_insert(i)
if not i then return false end
if game.player then -- the culprit, line 254
if game.player.character then
if (game.player.caninsert{name=i, count=1}==true) then
game.player.character.insert{name=i, count=1}
return true
end
end
end
return false
end
game.onevent(defines.events.onbuiltentity, function(event)
local is_floor=false
for _, ftype in ipairs(floor_types) do
if (event.createdentity.name==ftype) then is_floor=true end
end
if (is_floor==true) then
update_area(event.createdentity.position.x,event.createdentity.position.y,event.createdentity.name)
elseif (event.createdentity.name=="floor-b-gone") then
delete_area(event.createdentity.position.x,event.createdentity.position.y)
safe_insert("floor-b-gone")
elseif (event.createdentity.name=="floor-o-matic") then
flooromatic(event.createdentity.position.x,event.createdentity.position.y)
safe_insert("floor-o-matic")
end
end)
Code: Select all
for i, player in ipairs(game.players) do
-- call player functions here
end