Add launch target surface to `on_cargo_pod_finished_ascending`
Posted: Wed Jan 08, 2025 1:43 pm
TLDR: Add the cargo pod launch target to the `on_cargo_pod_finished_ascending`, storing a `LuaSurface` or at least the surface ID for standard launches and `nil` for launching to orbit.
Currently the `on_cargo_pod_finished_ascending` lets us read whether the cargo pod was launched by a rocket silo or a platform (via `launched_by_rocket` bool) and we can get the launch surface by reading the `surface` of the cargo pod `LuaEntity`. As far as I can tell, there is no way of getting where the cargo pod was launched TO.
My specific use case for this is my Power Satellites mod. The player can use the rocket silo to launch the power satellites to orbit, like they would launch satellites in a non-SA game. Satellites launched to orbit are expended and start generating power received by receiver buildings on the ground. My issue is that since there is no way to determine whether the rocket was launched to the orbit or to a platform, every launch increases the power generation. This creates a minor exploit whereby the player can launch a single powersat to the platform to get more power, then send it back down to be infinitely reused. I could fix that by delaying the power generation trigger, using `on_cargo_pod_finished_ascending` to store the cargo pod and launch surface then check stored values in `on_tick` or `on_nth_tick`, but adding additional checks on every (nth) tick seems like a pretty expensive operation for something that happens exactly once on every launch event.
I think having the target surface in `on_cargo_pod_finished_ascending` event would also be beneficial for space platform modding. One idea that came to me was a special platform (belonging to a different force) that the player could send some items to, either as a way of trading or completing some mod-specific objective.
Currently the `on_cargo_pod_finished_ascending` lets us read whether the cargo pod was launched by a rocket silo or a platform (via `launched_by_rocket` bool) and we can get the launch surface by reading the `surface` of the cargo pod `LuaEntity`. As far as I can tell, there is no way of getting where the cargo pod was launched TO.
My specific use case for this is my Power Satellites mod. The player can use the rocket silo to launch the power satellites to orbit, like they would launch satellites in a non-SA game. Satellites launched to orbit are expended and start generating power received by receiver buildings on the ground. My issue is that since there is no way to determine whether the rocket was launched to the orbit or to a platform, every launch increases the power generation. This creates a minor exploit whereby the player can launch a single powersat to the platform to get more power, then send it back down to be infinitely reused. I could fix that by delaying the power generation trigger, using `on_cargo_pod_finished_ascending` to store the cargo pod and launch surface then check stored values in `on_tick` or `on_nth_tick`, but adding additional checks on every (nth) tick seems like a pretty expensive operation for something that happens exactly once on every launch event.
I think having the target surface in `on_cargo_pod_finished_ascending` event would also be beneficial for space platform modding. One idea that came to me was a special platform (belonging to a different force) that the player could send some items to, either as a way of trading or completing some mod-specific objective.