Page 1 of 1

Where is stored tree colision box?

Posted: Wed Apr 20, 2022 10:22 am
by MateuszCOMPANY
In which file is stored tree collision box?
Have modified string but don't understand from it where is source

Code: Select all

for _,tree in pairs(data.raw["tree"]) do
   tree.collision_box = {{-0.05, -0.05}, {0.05, 0.05}}
end

Re: Where is stored tree colision box?

Posted: Wed Apr 20, 2022 10:28 am
by boskid
If you are looking for where are the collision_boxes defined for trees in base mod, then they are located in "data/base/prototypes/entity/trees.lua" where they are generated from tree_data: line 7302 inside of a for-loop starting at line 7148. There are also other trees defined in this file which are not going through the tree_data and they have separate collision_boxes data in this file.

Re: Where is stored tree colision box?

Posted: Wed Apr 20, 2022 10:38 am
by MateuszCOMPANY
Thanks ;)

Edit.
Another question, there is other mod changing tree collision box to tinny but which value cause it?
It cant be {-0.4, -0.4}, {0.4, 0.4} because its default factorio value.
After apply this mod tree collision box becomes around {-0.05, -0.05}, {0.05, 0.05} like in previous mod
But where is there executive value?

Code: Select all

local normalizeTreeCollision = settings.startup["sapling-capsule-normalize-collision-box"].value
if normalizeTreeCollision then
	for i, v in pairs( data.raw.tree ) do
		if v.collision_box[2][1] < 0.4 then
			v.collision_box = {{-0.4, -0.4}, {0.4, 0.4}}
		end
	end
end

Re: Where is stored tree colision box?

Posted: Wed Apr 20, 2022 12:12 pm
by Pi-C
MateuszCOMPANY wrote: Wed Apr 20, 2022 10:38 am Thanks ;)

Edit.
Another question, there is other mod changing tree collision box to tinny but which value cause it?
It cant be {-0.4, -0.4}, {0.4, 0.4} because its default factorio value.
After apply this mod tree collision box becomes around {-0.05, -0.05}, {0.05, 0.05} like in previous mod
But where is there executive value?
I guess the other mod is loaded after yours (check factorio-current.log!), so it will overwrite any changes you've made. The fix is easy: just apply your changes after the other mod is done!

Check out the code of the other mod -- when does it change the collision boxes? If it happens in data.lua, change the collision boxes yourself in data-updates.lua; if the other mod makes the changes in data-updates.lua, move your code to data-final-fixes.lua.

If the other mod is loaded after yours and is making the changes in data-final-fixes.lua, you can't move your code to a later stage. However, you can enforce that the other mod will be loaded before yours by adding an optional ("? other_mod") or hidden optional ("(?) other_mod") dependency on it to your info.json.

Re: Where is stored tree colision box?

Posted: Wed Apr 20, 2022 12:39 pm
by MateuszCOMPANY
Your right, there was conflict with other mod causing it.
This mod work with second way. change tiny box collision to default.
My bad, Thanks for help ;)

Re: Where is stored tree colision box?

Posted: Wed Apr 20, 2022 3:33 pm
by Pi-C
You're welcome, nice that it's working now! :mrgreen: