Inter-force interactions
Posted: Sun Mar 06, 2016 9:14 pm
Right now, with the lua api, we can allow a ceasefire between two forces:
Now, there is still one problem, in that a force should allow another to access containers and open doors.
Something like:
This could solve a number of problems when making PvP multiplayer games, such as trains crashing through doors, impossibility of efficient trading, and neutral doors not letting any players through.
Right now, I'm using a small workaround for trading:
But such behavior should be achievable much more easily.
Code: Select all
my_force.set_cease_fire(their_force, true)
Something like:
Code: Select all
my_force.set_interaction_permission(their_force, true)
Right now, I'm using a small workaround for trading:
Code: Select all
-- some entities are always neutral to allow for inter-faction trading
always_neutral = {
"wooden-chest",
"cargo-wagon",
-- "diesel-locomotive",
"straight-rail",
"curved-rail",
}
script.on_event(defines.events.on_built_entity, function (event)
local entity = event.created_entity
for _,neutral_entity in ipairs(always_neutral) do
if (entity.name == neutral_entity) then
entity.force = "neutral"
return
end
end
end)