For entity-ghost, add LuaEntity.get_train_schedule()

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
BinarySpike
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jun 28, 2016 2:15 am
Contact:

For entity-ghost, add LuaEntity.get_train_schedule()

Post by BinarySpike »

I'm trying to extend my mod Blueprint Variables to support train schedules. When a player places a blueprint, for various reasons, I inspect the `entity-ghost` (LuaEntity) for variables (virtual signals). Currently I'm using `get_control_behavior()` for circuits, `supports_backer_name()` for train station names, (unimplemented) `get_request_slot()` for logistic chests, (unimplemented) `get_filter()` for filter inserters.

However, there is no corresponding way to access a locomotive `entity-ghost` train schedule to check for station names and wait conditions with virtual signals in it (or entity prototypes? for item related stuff).

A workaround I found, would be to `revive()` the locomotive (detect if it has track ghosts, revive those, then create any missing tracks) and then check the returned entities schedule. Then unwind the change.

A new method to access a ghost entity's train would be optimal, but doesn't seem feasible based on what I know of the API. Such as extending `LuaEntity.train` to return the LuaTrain of the entity-ghost locomotive.

If that's not possible, a much more feasible approach might be to add something like LuaEntity.get_train_schedule() to return a locomotive's train schedule or an entity-ghost locomotive's train schedule. Read-only of the train schedule stations would be fine for me, because I only need to detect variables at this point. They get hydrated once the variable selection GUI is submitted.
Last edited by BinarySpike on Fri Oct 20, 2023 5:39 am, edited 1 time in total.

BinarySpike
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jun 28, 2016 2:15 am
Contact:

Re: For entity-ghost, add LuaEntity.get_train_schedule()

Post by BinarySpike »

Another possible change would be adding `entity_number` in the `event` so the ghost-item can be correlated back to the `event.stack.get_blueprint_entities()` list—which has `entity_number` and `schedule` properties. This would have the added benefit of being able to correlate other entity-ghosts to blueprint entities.

In the meantime, the workaround I'm going to implement, is analyze all the locomotives in the blueprint entities, every time I see an entity-ghost locomotive built.

Post Reply

Return to “Modding interface requests”