[Quick fix] modify resource spacing with collision_box
Posted: Thu Feb 16, 2017 2:07 am
I like to play with unlimited richness. When using autoplace controls I increase the size of the resource collision_box to give the patches some nice spacing, and to limit the "spray and pray" nature of miner placement. After being introduced to RSO its hard to go back to old resource placement but I discovered that the RSO placement does not respect the collision box of entities.
I've added in a quick fix at line 691 of control.lua. It does not seem to affect chunk loading times greatly.
This could also fix an issue with oilwells spawning really spread out in RSO.
I've added in a quick fix at line 691 of control.lua. It does not seem to affect chunk loading times greatly.
Code: Select all
local box = game.entity_prototypes[spawnName].collision_box
local absolute_box = {left_top={box.left_top.x+location.x+resOffsetX,box.left_top.y+location.y+resOffsetY},right_bottom={box.right_bottom.x+location.x+resOffsetX,box.right_bottom.y+location.y+resOffsetY}}
local colliders = surface.count_entities_filtered{
area = absolute_box,
type = "resource"
}
if amount > 0 and colliders == 0 then
surface.create_entity{
name = spawnName,
position = {location.x + resOffsetX,location.y + resOffsetY},
force = game.forces.neutral,
amount = amount}
end