Where is stored tree colision box?

Place to get help with not working mods / modding interface.
MateuszCOMPANY
Inserter
Inserter
Posts: 39
Joined: Wed Mar 09, 2022 12:36 am
Contact:

Where is stored tree colision box?

Post 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
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4054
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Where is stored tree colision box?

Post 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.
MateuszCOMPANY
Inserter
Inserter
Posts: 39
Joined: Wed Mar 09, 2022 12:36 am
Contact:

Re: Where is stored tree colision box?

Post 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
Pi-C
Smart Inserter
Smart Inserter
Posts: 1759
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Where is stored tree colision box?

Post 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.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
MateuszCOMPANY
Inserter
Inserter
Posts: 39
Joined: Wed Mar 09, 2022 12:36 am
Contact:

Re: Where is stored tree colision box?

Post 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 ;)
Pi-C
Smart Inserter
Smart Inserter
Posts: 1759
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Where is stored tree colision box?

Post by Pi-C »

You're welcome, nice that it's working now! :mrgreen:
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Post Reply

Return to “Modding help”