ObjectStack extension issue

Hey pals,

I’d like to propose a fix for the ObjectStack extension to make it compatible with the Save State feature.

Now, I’m not sure whether this is due to a bug or whether it should be considered a feature request, but I noticed that the object’s last stack is not saved/loaded properly.

This results in an incompatibility that I believe needs to be fixed.

I’ve tried to reproduce the issue that has been affecting me since the Save State feature was released, using a minimal project that I hope can help identify and resolve the problem.

However, I may have made some mistakes or inaccuracies when creating it, so if you find any errors in my example, I’d appreciate it if you could let me know.

to operate:

a,s key swap stack.

f5 to save

f6 to load

occasionally it fails to load properly.even with others load option.

This force the user to do workarounds at loads to re-set the stack the object is in.

Hi! Thanks for the clear report and the repro project, I had a look.

You are right this is not working, the way it remembers which
objects are in a stack isn’t compatible with the Save State feature. When a save is loaded, some objects are recreated behind the scenes, and the extension
loses track of them — which is why it only fails sometimes. Until the extension is updated, your workaround (rebuilding the stack after loading) is the
right approach.

In order for it to work, the extension (on the extensions repository GitHub - GDevelopApp/GDevelop-extensions: Repository of behaviors, actions, conditions and expressions to be used in GDevelop for creating games · GitHub) needs to be updated

For anyone interested in doing it, the built-in LinkedObjects extension solved a similar problem and is a good model: see the
registerRuntimeSceneGetSyncDataCallback / registerRuntimeSceneUpdateFromSyncDataCallback calls at the bottom of Extensions/LinkedObjects/linkedobjects.ts
We can probably save the stacks as lists of object networkIds, and rebuild them from those ids when a save is loaded.

cc @davy

Thanks a lot for the information! Despite the issue, I’m actually glad it’s an incompatibility issue and not something I messed up.

I’ve looked like the village idiot in a few other threads because I was trying to explain this issue and nobody else seemed to understand what I meant. :grinning_face_with_smiling_eyes:

I have to admit that tracking it down and isolating the cause wasn’t easy this time. It’s a pretty sneaky bug.

For now, after Load succeeded, I’m just resetting/recreating the stack as a workaround.

I’ll wait for the official fix so I can simplify my event sheet.

Thanks again.