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.
Flag to force prototype placement on rail grid
-
- Long Handed Inserter
- Posts: 54
- Joined: Mon Aug 27, 2018 12:46 pm
- Contact:
Re: Flag to force prototype placement on rail grid
The workaround is to listen for the build event, calculate the expected position, and rebuild or refund the building if it does not match.
-
- Long Handed Inserter
- Posts: 54
- Joined: Mon Aug 27, 2018 12:46 pm
- Contact:
Re: Flag to force prototype placement on rail grid
You cant calculate the expected position because you are exactly halfway between 2 or 4 valid positions.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 can refund if its off but then player has a 1 in 4 chance of getting it right.
-
- Long Handed Inserter
- Posts: 54
- Joined: Mon Aug 27, 2018 12:46 pm
- Contact:
Re: Flag to force prototype placement on rail grid
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.
EDIT: turns out my workaround has some issues.
Allow entity prototypes to specify their building grid alignment/size
So that e.g. they can be aligned with rails.
bubbels (sic)
- Muppet9010
- Filter Inserter
- Posts: 279
- Joined: Sat Dec 09, 2017 6:01 pm
- Contact:
Re: Flag to force prototype placement on rail grid
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.
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
Implemented for 1.1.62:
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.
Only values 1 or 2 will be allowed. Rails, Rail Remnants and Train Stops will overwrite this value to 2 (hardcoded grid size).1.1.62 wrote:Modding:
- Added EntityPrototype::build_grid_size. Supported values are 1 (for 1x1 grid) and 2 (for 2x2 grid).
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.