[Quick fix] modify resource spacing with collision_box

Replaces resource spawning system, so that the distances between resources are much bigger. Railway is needed then.

Moderators: orzelek, Dark

Post Reply
abregado
Former Staff
Former Staff
Posts: 282
Joined: Sat Aug 30, 2014 9:43 am
Contact:

[Quick fix] modify resource spacing with collision_box

Post by abregado »

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.

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
This could also fix an issue with oilwells spawning really spread out in RSO.

abregado
Former Staff
Former Staff
Posts: 282
Joined: Sat Aug 30, 2014 9:43 am
Contact:

Re: [Quick fix] modify resource spacing with collision_box

Post by abregado »

Oh it seems I missed http://lua-api.factorio.com/latest/LuaS ... ace_entity
which would also work.

Post Reply

Return to “Resource Spawner Overhaul”