[1.1.2] Expose train stop limit information to Lua

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
Mooeing-747
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri May 22, 2020 6:56 pm
Contact:

[1.1.2] Expose train stop limit information to Lua

Post by Mooeing-747 »

I'd like to be able to read the current train limit of a station in a mod, but it doesn't seem to be exposed to Lua? I'm guessing I can get the number of trains that have reserved the station with a combination of `get_stopped_train()` and checking the `path_end_stop` for each train in `get_train_stop_trains()`, but that feels clunky and, in addition, I can't find anything that gets/sets the limit of the stop.

Ideally, I think LuaEntity would expose two properties, `train_stop_limit [uint, RW]` and `train_stop_reserved_by [array of LuaTrain, R]`

Happy to be pointed to the appropriate properties if they already exist.
Known as moogan in game.


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

Re: [1.1.2] Expose train stop limit information to Lua

Post by boskid »

Path of 1.1.0 changelog:

Code: Select all

    - Added LuaEntity::trains_limit read/write.
    - Added LuaEntity::trains_count read.
    - Added LuaTrainStopControlBehavior::trains_count_signal, trains_limit_signal, set_trains_limit and read_trains_count read/write.
(they may have wrong returned type in doc saying LuaEntity while they return uint, this will be fixed in 1.1.3 doc)

General problem with the `train_stop_reserved_by` is that it is not a simply given value: i would have to visit all the trains and check if they have any reservation of a given train stop (due to waypoints logic train may have reservation for multiple train stops at once, even for the same one multiple times). Issue would be that the trains count could say 10 and if asked for train_stop_reserved_by it would only return (for example) 8 trains. It may still be better than doing that check lua side so it may still be good idea to have that.

Mooeing-747
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri May 22, 2020 6:56 pm
Contact:

Re: [1.1.2] Expose train stop limit information to Lua

Post by Mooeing-747 »

I control-f'd for `limit` in the entity docs but I must have been bitten by a cache issue. Ah well, thanks for the sanity check!
Known as moogan in game.

Post Reply

Return to “Modding interface requests”