Page 1 of 1

biter pathfinding collision box mod

Posted: Tue May 15, 2018 2:11 pm
by sthalik
Hey,

Could you please write a short mod modifying existing entities, as follows?

Let me provide a list of entity names as an array and a value by which I can multiply their collision box. I'd like to multiply collision box elements by that value, making the box bigger or smaller, for testing. This concerns biter pathfinding. I'd like to experiment with either oversized or very small collision boxes.

I have trouble understanding how to extend existing entities without copy-pasting them from data.raw. What I need is to specify entity prototype names and collision box scaling factor, without copy-pasting the entities.

I'd write it on my own but semantics of "data:extend(...)" for rewriting entities elude me :(

Re: biter pathfinding collision box mod

Posted: Tue May 15, 2018 2:47 pm
by eradicator

Code: Select all

local function box_scale (box,scale)
 return {{box[1][1]*scale,box[1][2]*scale},{box[2][1]*scale,box[2][2]*scale}}
 end

biter_list = { --biter name to box scale
 ["small-biter"] = 2,
 ["big-biter"] = 0.1,
  }

for name,scale in pairs(biter_list) do
  data.raw.unit[name].collision_box = box_scale(data.raw.unit[name].collision_box,scale)
  end
data:extend only adds a new subtable to the huge table that is "data", you can't change old ones with that. What you want is to directly manipulate existing table entries via data.raw.

Re: biter pathfinding collision box mod

Posted: Tue May 15, 2018 3:02 pm
by sthalik
Thank you very much.