How to reinitialize after loading from a save

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
Post Reply
argv
Posts: 184
Joined: Tue Aug 30, 2016 4:47 pm

How to reinitialize after loading from a save

Post by argv »

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.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: How to reinitialize after loading from a save

Post by Apeirogon »

Examlple of what you want?
User avatar
krokots
Posts: 296
Joined: Tue Jan 19, 2010 5:07 pm

Re: How to reinitialize after loading from a save

Post by krokots »

I think event

Code: Select all

void WorldLoaded(WorldEvent e)
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.
argv
Posts: 184
Joined: Tue Aug 30, 2016 4:47 pm

Re: How to reinitialize after loading from a save

Post by argv »

Ah, you're right, the WorldLoaded event should do what I need. Thanks!
Post Reply

Return to “Scripting”