force_visibility = 'friend' should make a simple-entity-with-owner invisible to non-friend forces. However if the entity is on the neutral force it remains visible.
Reproduction
1) Apply force_visibility to built-in SEWO
Code: Select all
data.raw['simple-entity-with-owner']['simple-entity-with-owner'].force_visibility = "friend"
Code: Select all
/c
local function f (entity, friend)
for _, force in pairs(game.forces) do
--[[ make 110% sure that diplomacy is setup correctly ]]
entity.force.set_cease_fire(force, false)
force.set_cease_fire(entity.force, false)
entity.force.set_friend(force, friend)
force.set_friend(entity.force, friend)
end
end
local x, friend = {}, false
for _, force in pairs(game.forces) do
table.insert(x, game.player.surface.create_entity{
name = 'simple-entity-with-owner',
position = {game.player.position.x + force.index*2, game.player.position.y},
force = force,
})
end
script.on_nth_tick(30, function()
friend = not friend
for _, entity in pairs(x) do f(entity, friend) end
print(friend)
end)
The neutral force is by default in cease_fire/ally mode, so friend-only entities should not be visible to other forces.