Page 1 of 1

LuaEntityPrototype::secondary_collision_box is not exposed.

Posted: Thu Mar 28, 2019 9:41 pm
by dewiniaid
Some entities (i.e. curved rails) have a secondary collision box.

While this can be accessed on an entity itself (LuaEntity::secondary_bounding_box), it can't be accessed on entity prototypes.

I'm working on a feature to automatically add landfill to tiles that need it in a blueprint, so this is needed to be able to handle curved rails and anything else that might have odd collision boxes.

Re: LuaEntityPrototype::secondary_collision_box is not exposed.

Posted: Thu Mar 28, 2019 11:15 pm
by Boodals
I looked into this. secondary_collision_box only exists for rail and rail remnant prototypes, and they are translated and rotated when the rail is created. Being able to read it would only give you the size of it, not its position relative to the rail, nor its rotation.
The best you could do is make a lookup table that takes the direction of the curved rail and gives the collision box. That said, I will make a pull request to expose the untransformed collision box so if it is changed by mods for some reason, you can at least use it.
If you do make a lookup table, please post it here so that others can use it if they are looking for the same thing.

Re: LuaEntityPrototype::secondary_collision_box is not exposed.

Posted: Thu Mar 28, 2019 11:38 pm
by dewiniaid
Yup, I'm aware that priority prototype bounding boxes are relative to the origin and facing north. Transformed bounding boxes can be obtained from an entity directly, but I don't have a real entity available in this case.

The transformation itself is not too difficult though, I already have code for most of that.

Re: LuaEntityPrototype::secondary_collision_box is not exposed.

Posted: Fri Mar 29, 2019 2:02 am
by Boodals
The pull request was accepted already, it'll be in the next version of 0.17.