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.
Add launch target surface to `on_cargo_pod_finished_ascending`
Re: Add launch target surface to `on_cargo_pod_finished_ascending`
This should still be added, but
Can't you just remove your item from the cargo pod? Though I don't see the define, I assume the pod has an accessible inventory since it sounds like you are checking it.LCStark wrote: Wed Jan 08, 2025 1:43 pm 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.
Re: Add launch target surface to `on_cargo_pod_finished_ascending`
Hmm, I didn't think of that. If I could remove the satellite from the cargo pod in the `ascending` event after I've used it, then it would at least prevent the re-use of the same item over and over again. Though I think it might be confusing for players if they launch to a platform instead of orbit and see an empty cargo pod arriving with their satellite seemingly vanished. Plus it would prevent them from transporting the satellites to other planets if they want to outsource their production. I'll still have to try that and see if it works, thanks for the idea!curiosity wrote: Wed Jan 08, 2025 3:06 pm Can't you just remove your item from the cargo pod? Though I don't see the define, I assume the pod has an accessible inventory since it sounds like you are checking it.
It still leaves the issue of differentiating between launching to orbit vs launching to a platform to run the power generation code only when it should be ran. Having the target accessible would let me cleanly prevent both issues from occurring.