• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Best practice to duplicate sequence objects at runtime

Ulysse

Member
Hello,

In my title, I have several actions that might trigger an animation on screen, like a short cutscene describing an event. For those, I use sequences. However, part of those sequences must be adapted to the current context. In practice, it means I have to replace some sprites with the proper sprites created at runtime. So I created my sequence in the editor with some placeholders, and at runtime I am trying to change the sprite_index of some tracks in the sequence.

In addition, I might have several cases of the same sequence at the same time, so I can't modify the sequence object struct directly. I first need to make a copy of it. And that is where my issue comes.
I could not find a "sequence_copy" function or similar. So I created my own function, which go through each elements (since it is a struct, I can list them with variable_struct_get_names) and copy them into a newly created sequence. Of course, there are some special cases, as arrays like tracks need to be deep copied, to avoid ending up with both sequences referencing some common data.
The result is a pretty gruesome and complicated function, but it does the job.

With something so manual, I knew I would run into troubles around engine updates. And indeed, 2.3.1 seems to not treat sequence as struct anymore, making the copy much more complicated. I mentioned that in the 2.3.1 thread, but I don't know at this point if it is a bug or an intended evolution of the sequence format. I can probably work around that by listing elements manually, but it would make my copy function even more specific to the current format of sequences.
All this really shows the weaknesses of my current tactic.

Hence my question: is there are smart way to duplicate an existing sequence? Failing that, is there a plan to add such a feature?
 
Top