I have some ZScript classes with some transient fields. When instances of those classes are loaded from a save file, I need to fill in those transient fields again.
Is there a way to do this immediately upon loading? I can of course fill in transient fields lazily, but I'd rather not incur the performance hit of checking on every tic if I don't have to.
How to reinitialize after loading from a save
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Re: How to reinitialize after loading from a save
Examlple of what you want?
Re: How to reinitialize after loading from a save
I think event is what you are looking for. e.IsSaveGame returns true if you loaded a save. I'll write an example if you don't know much about events in ZScript.
Code: Select all
void WorldLoaded(WorldEvent e)
Re: How to reinitialize after loading from a save
Ah, you're right, the WorldLoaded event should do what I need. Thanks!