biter pathfinding collision box mod

This is the place to request new mods or give ideas about what could be done.
Post Reply
sthalik
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Tue May 01, 2018 9:32 am
Contact:

biter pathfinding collision box mod

Post 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 :(

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: biter pathfinding collision box mod

Post 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.

sthalik
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Tue May 01, 2018 9:32 am
Contact:

Re: biter pathfinding collision box mod

Post by sthalik »

Thank you very much.

Post Reply

Return to “Ideas and Requests For Mods”