Do you mean something like this? Please, create the mod.Oktokolo wrote: Sun Sep 01, 2019 7:10 pmA minimum distance from other ports should be enforcable in build event handlers.redis wrote: Sun Sep 01, 2019 4:13 pm Yes, definitely no gaps. So I agree may be some small overlap in range could be allowed, but roboports must be spaced out from each other.
Now we only need someone less lazy than me to actually mod it.
Code: Select all
--control.lua
INTERFERENCE_RANGE = 50
function IsEntityRoboport(entity)
if entity.name == "entity-ghost" then if entity.ghost_name == "roboport" then return true end
else if entity.name == "roboport" then return true end end
return false
end
script.on_event(defines.events.on_built_entity, function(event)
local entity = event.created_entity
local player = game.players[event.player_index]
local pos = { x = entity.position.x, y = entity.position.y }
if IsEntityRoboport(entity) then
local offset = INTERFERENCE_RANGE - 2
local interference_area = {{pos.x - offset, pos.y-offset}, {pos.x + offset, pos.y + offset}}
local entities = game.surfaces[1].find_entities_filtered{name = {"roboport"}, area = interference_area}
--local entities = game.surfaces[1].find_entities_filtered{name = {"roboport"}, position = pos, radius = interference-area}
for _, e in pairs(entities) do
if e ~= entity then
if entity.name ~= "entity-ghost" then -- If the item is not a ghost insert it back to the player.
player.insert({name = entity.name, count = 1})
end
entity.destroy()
game.print("Roboports logistic range can not overlap.")
return
end
end
end
end
)