Reset CVAR on Startup?

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
Heisanevilgenius
Posts: 93
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Reset CVAR on Startup?

Post by Heisanevilgenius »

I'm trying to have a custom CVAR reset to default whenever you open GZDoom. I want to make sure players don't accidentally leave it active when unwanted because it's an optional setting that can make gameplay extremely unfun.

I tried:

Code: Select all

Class ResetAnnoyer : StaticEventHandler
{
	override void OnEngineInitialize()
	{
		Cvar.ResetToDefault("my_cvar");
	}
}
But it won't let me do that because resetting the CVAR is a non-static command and OnEngineInitialize is a Static Event Handler.

I get this error message:

Code: Select all

Cannot call non-static function CVar::ResetToDefault from here
Is there a way around this?

Thanks
User avatar
phantombeta
Posts: 2159
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Reset CVAR on Startup?

Post by phantombeta »

For the specific purpose you want, you should be able to just set the CVAR as noarchive in CVARINFO instead.
Heisanevilgenius
Posts: 93
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Reset CVAR on Startup?

Post by Heisanevilgenius »

Thank you so much, that's exactly what I wanted.
Post Reply

Return to “Scripting”