surface.create_entity does not respect collision boxes
Posted: Thu Feb 16, 2017 2:08 am
Discovered this while messing with autoplace controls. Increasing the size of a resources Collision Box causes the autoplace controls to nicely space out the resource tiles. After trying this with a custom script to spawn objects in a field I discovered that Surface.create_entity does not respect collision boxes.
Could there be an option in create_entity to force placement or respect collision?
I used this code in my control.lua to demonstrate the issue
Could there be an option in create_entity to force placement or respect collision?
I used this code in my control.lua to demonstrate the issue
Code: Select all
script.on_event(defines.events.on_chunk_generated, function(event)
local boundingBox = event.area
local surface = event.surface
local pos1 = boundingBox.left_top
local pos2 = {boundingBox.left_top.x+1,boundingBox.left_top.y+1}
local pos3 = {boundingBox.left_top.x+2,boundingBox.left_top.y+2}
local ent1 = surface.create_entity({
name="assembling-machine-1",
position=pos1,
force='player'
})
surface.create_entity({
name="assembling-machine-1",
position=pos2,
force='player'
})
surface.create_entity({
name="iron-ore",
position=pos3,
})
end)