Requesting an event for when a cutscene ends

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
asher_sky
Inserter
Inserter
Posts: 30
Joined: Sun Oct 18, 2020 7:13 pm
Contact:

Requesting an event for when a cutscene ends

Post 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 :)

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5030
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Requesting an event for when a cutscene ends

Post by Klonan »

Whats wrong with just using on_cutscene_waypoint_reached and knowing which one is the final one?

asher_sky
Inserter
Inserter
Posts: 30
Joined: Sun Oct 18, 2020 7:13 pm
Contact:

Re: Requesting an event for when a cutscene ends

Post 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?

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5202
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Requesting an event for when a cutscene ends

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 703
Joined: Sun May 07, 2017 10:16 am
Contact:

Re: Requesting an event for when a cutscene ends

Post 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.
Mods: Shortcuts for 1.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write

Pi-C
Smart Inserter
Smart Inserter
Posts: 1274
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Requesting an event for when a cutscene ends

Post 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. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Post Reply

Return to “Modding interface requests”