Page 1 of 1

Flag to force prototype placement on rail grid

Posted: Mon Jun 01, 2020 5:14 pm
by Phoenix27833
I would like something which forces placement of the prototype on the rail grid, (the way it works with rails and train-stops)
eg "placeable-rail-grid" flag in EntityPrototypeFlags
This would allow creation of modded entities related to the rail grid.
Currently this is only achievable by basing the modded entity on a:
rail - cannot modify collision box
train-stop - can only place next to rail.

Re: Flag to force prototype placement on rail grid

Posted: Mon Jun 01, 2020 5:30 pm
by DaveMcW
The workaround is to listen for the build event, calculate the expected position, and rebuild or refund the building if it does not match.

Re: Flag to force prototype placement on rail grid

Posted: Mon Jun 01, 2020 6:14 pm
by Phoenix27833
The workaround is to listen for the build event, calculate the expected position, and rebuild or refund the building if it does not match.
You cant calculate the expected position because you are exactly halfway between 2 or 4 valid positions.
You can refund if its off but then player has a 1 in 4 chance of getting it right.

Re: Flag to force prototype placement on rail grid

Posted: Mon Jun 01, 2020 9:06 pm
by Phoenix27833
I found a workaround using the train-stop which seems to work in my case (it hasn't broken anything yet), so I probably don't need this anymore.

EDIT: turns out my workaround has some issues.

Allow entity prototypes to specify their building grid alignment/size

Posted: Sun Jun 14, 2020 8:31 pm
by tubs
So that e.g. they can be aligned with rails.

Re: Flag to force prototype placement on rail grid

Posted: Sun Jul 03, 2022 7:26 pm
by Muppet9010
Yea I hit this as well.
Had to do a whole process to; catch build, review validity, if bad refund and show to player valid placement positions.
Was a bunch of code and added complexity to work around this issue.

Re: Flag to force prototype placement on rail grid

Posted: Tue Jul 05, 2022 5:45 am
by boskid
Implemented for 1.1.62:
1.1.62 wrote:Modding:
- Added EntityPrototype::build_grid_size. Supported values are 1 (for 1x1 grid) and 2 (for 2x2 grid).
Only values 1 or 2 will be allowed. Rails, Rail Remnants and Train Stops will overwrite this value to 2 (hardcoded grid size).

This value corresponds to a LuaEntityPrototype::building_grid_bit_shift read from the control stage. Name of this field is highly missleading because it may be based on a invalid comment in the source code. This field returns a value which directly gives size in tiles. It may happen that i will rename this field to be more accurate (like "build_grid_size") but this is not yet decided.