For entity-ghost, add LuaEntity.get_train_schedule()
Posted: Fri Oct 20, 2023 3:12 am
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.
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.