Flag to force prototype placement on rail grid

Post Reply
Phoenix27833
Inserter
Inserter
Posts: 47
Joined: Mon Aug 27, 2018 12:46 pm
Contact:

Flag to force prototype placement on rail grid

Post 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.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Flag to force prototype placement on rail grid

Post 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.

Phoenix27833
Inserter
Inserter
Posts: 47
Joined: Mon Aug 27, 2018 12:46 pm
Contact:

Re: Flag to force prototype placement on rail grid

Post 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.

Phoenix27833
Inserter
Inserter
Posts: 47
Joined: Mon Aug 27, 2018 12:46 pm
Contact:

Re: Flag to force prototype placement on rail grid

Post 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.

tubs
Burner Inserter
Burner Inserter
Posts: 15
Joined: Tue Jan 06, 2015 7:29 pm
Contact:

Allow entity prototypes to specify their building grid alignment/size

Post by tubs »

So that e.g. they can be aligned with rails.
bubbels (sic)

User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

Re: Flag to force prototype placement on rail grid

Post 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.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2244
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Flag to force prototype placement on rail grid

Post 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.

Post Reply

Return to “Implemented mod requests”