https://i.imgur.com/o3aM936.png
Code: Select all
local master_entities = surface.find_entities({master_pos, {master_pos.x+32, master_pos.y+32}})
for _, entity in ipairs(master_entities) do
if entity.type ~= "character" and entity.type ~= "player" then
local amount = entity.type == "resource" and entity.amount or nil
surface.create_entity{
name= entity.name,
position= {
x= (entity.position.x - master_pos.x) * slave_dx + slave_pos.x,
y= (entity.position.y - master_pos.y) * slave_dy + slave_pos.y
},
direction= entity.direction,
force= entity.force,
-- TODO: more thorough cloning
-- type-specific parameters
amount= amount,
}
end
end