Page 1 of 1

Requesting an event for when a cutscene ends

Posted: Mon Apr 19, 2021 6:48 pm
by asher_sky
Re: viewtopic.php?f=30&t=97943
I would like to formally request that on_cutscene_cancelled() be called when a cutscene ends on its own, OR we get a separate event (e.g. on_cutscene_ended) for when a cutscene ends without being cancelled.

Thanks :)

Re: Requesting an event for when a cutscene ends

Posted: Mon Apr 19, 2021 9:37 pm
by Klonan
Whats wrong with just using on_cutscene_waypoint_reached and knowing which one is the final one?

Re: Requesting an event for when a cutscene ends

Posted: Mon Apr 19, 2021 11:44 pm
by asher_sky
There's nothing wrong with that per se, you're right I could just keep track of how many waypoints there are and store that in a global like I'm doing for the waypoint target and other various data.

My specific use case is that since I already store lots of things in global, I want to nil them all when the cutscene ends. Previously that happened immediately after I call player.exit_cutscene(), but now I've changed it so that when a player wants to exit the cutscene, I create a new cutscene to transition them nicely back to their character instead of immediately cutting. However, that means the cutscene ends "naturally" and I don't have a chance to nil my globals because I don't know when it actually ends. If I use on_cutscene_waypoint_reached I would then have to store more globals because the cutscene waypoint being reached would be 1, and most of my cutscenes typically have 2 or sometimes 3 waypoints that can be reached.

It's not really that big of a deal, like a lot of things I've found while playing with the cutscene controller, of course there are ways to work around it. I just thought it would be nice.

I assume that's how you do it for the crash-site cutscene; player.exit_cutscene() when the correct on_cutscene_waypoint_reached is called?

Re: Requesting an event for when a cutscene ends

Posted: Mon Apr 19, 2021 11:58 pm
by eradicator
Klonan wrote:
Mon Apr 19, 2021 9:37 pm
Whats wrong with just using on_cutscene_waypoint_reached and knowing which one is the final one?
That doesn't work when waiting for a cutscene that was started by another mod.

Re: Requesting an event for when a cutscene ends

Posted: Tue Mar 29, 2022 3:00 pm
by ickputzdirwech
I would like to request an event called on_player_controller_changed or something similar.

As I understand it this could solve the issue presented here as well (that's why I am posting here).

My use case is that I want to know when another mod changes the controller. There already is on_player_toggled_map_editor but obviously mods use other controllers as well.

Re: Requesting an event for when a cutscene ends

Posted: Tue Mar 29, 2022 3:43 pm
by Pi-C
ickputzdirwech wrote:
Tue Mar 29, 2022 3:00 pm
I would like to request an event called on_player_controller_changed or something similar.


My use case is that I want to know when another mod changes the controller. There already is on_player_toggled_map_editor but obviously mods use other controllers as well.
Agreed, such an event could be useful. In my character-selector mod I wouldn't have to rely on other mods informing me that they are about to change to the controller type.

The only potential problem I can see is that changes from or to god mode would be triggered a lot. You don't have to use player.set_controller directly for that, it's sufficient to set/unset player.character. So changing characters the convenient way using

Code: Select all

player.character = nil
player.create_character("new_character")
would trigger the event twice. I suppose this could be worked around with

Code: Select all

new_char = player.surface.create_entity{name = "new_character", position = player.position, force = player.force}
player.character = new_char
but of course, it's not as obvious and convenient. :-)