Cvar Replacement?

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
User avatar
TXTX
Posts: 195
Joined: Thu Sep 12, 2013 5:53 pm
Location: A Hidden Location

Cvar Replacement?

Post by TXTX »

Is there a way to save strings and data that will be saved in game without using cvars? Using too many of them will end up crashing the game and I want to know if there's a workaround.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Cvar Replacement?

Post by Apeirogon »

Everything saves in save. Well, almost everything, but those that not saves are very specific edge cases.
Or you mean saves between different game sessions?
User avatar
TXTX
Posts: 195
Joined: Thu Sep 12, 2013 5:53 pm
Location: A Hidden Location

Re: Cvar Replacement?

Post by TXTX »

Apeirogon wrote:Everything saves in save. Well, almost everything, but those that not saves are very specific edge cases.
Or you mean saves between different game sessions?
Like if you decide to save a game but come back to it later. Not sure if everything saves that way.
For example having a string saved to a static event handler or something.
User avatar
3saster
Posts: 199
Joined: Fri May 11, 2018 2:39 pm
Location: Canada

Re: Cvar Replacement?

Post by 3saster »

TXTX wrote: Like if you decide to save a game but come back to it later. Not sure if everything saves that way.
For example having a string saved to a static event handler or something.
In this particular case, the string saved in the static event handler is NOT saved, since the static event handlers are created on startup, and exist outside the scope of the playsim.
TXTX wrote:Is there a way to save strings and data that will be saved in game without using cvars? Using too many of them will end up crashing the game and I want to know if there's a workaround.
Anything that is part of the playsim (actors, etc.) will have their properties serialized and saved into the savegames. Thus, if, say, an actor stores some data on themselves, when the game is reloaded from a save, that data (at the point of the save) will be restored. If, however, you want persistant NON-playsim data (for example, a flag that says whether you beat the final boss before), CVARs are currently your only option. There have been discussions about this being implemented (can't find them atm), but I don't believe it will happen anytime soon. For now, you must rely on CVARs for persistant non-playsim data.
User avatar
TXTX
Posts: 195
Joined: Thu Sep 12, 2013 5:53 pm
Location: A Hidden Location

Re: Cvar Replacement?

Post by TXTX »

3saster wrote: In this particular case, the string saved in the static event handler is NOT saved, since the static event handlers are created on startup, and exist outside the scope of the playsim.

Anything that is part of the playsim (actors, etc.) will have their properties serialized and saved into the savegames. Thus, if, say, an actor stores some data on themselves, when the game is reloaded from a save, that data (at the point of the save) will be restored. If, however, you want persistant NON-playsim data (for example, a flag that says whether you beat the final boss before), CVARs are currently your only option. There have been discussions about this being implemented (can't find them atm), but I don't believe it will happen anytime soon. For now, you must rely on CVARs for persistant non-playsim data.
Thank you for the helpful reply. Suppose I can't do much about it unless I find some hacky way of implementing for now.
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: Cvar Replacement?

Post by gwHero »

TXTX wrote:Is there a way to save strings and data that will be saved in game without using cvars? Using too many of them will end up crashing the game and I want to know if there's a workaround.
There are global variables https://zdoom.org/wiki/ZScript_global_variables
User avatar
TXTX
Posts: 195
Joined: Thu Sep 12, 2013 5:53 pm
Location: A Hidden Location

Re: Cvar Replacement?

Post by TXTX »

gwHero wrote: There are global variables https://zdoom.org/wiki/ZScript_global_variables
I'll have to take a look at that. Should be helpful.
Post Reply

Return to “Scripting”