API access to rolling stock's rail layer

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
half a cat
Inserter
Inserter
Posts: 41
Joined: Sun Jul 16, 2023 4:03 pm
Contact:

API access to rolling stock's rail layer

Post by half a cat »

An entity's location is generally represented by MapPosition in the API. However, when elevated rails overlap with ground rails, MapPosition is not sufficient to identify the location of rolling stock. I am requesting for rail layer information to be included in the API:

* When reading the location of rolling stock, mods should be able to read which rail layer it is on
* When creating rolling stock with create_entity, mods should be able to control which rail layer it is created on

Because of this issue, my mod causes trains to unexpectedly jump from one rail layer to the other. The mod reads an entity's position, removes the entity, and creates a replacement at the same position. Since the position is ambiguous, the train unexpectedly jumps layers.

The attached save file reproduces the problem. The player is riding a locomotive on the bottom rail layer. After loading the save file, move the engine from the player's inventory into the locomotive's equipment grid. From the viewpoint of the player, this causes the locomotive to jump to the top rail layer.
Attachments
train-demo.zip
(1.76 MiB) Downloaded 21 times
Post Reply

Return to “Modding interface requests”