[SOLVED]Switchable menu option for a script

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
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

[SOLVED]Switchable menu option for a script

Post by Grey-Wolf »

Hello,
I made an ENTER script that gives the player a reward crate of goodies and equip if he manages to kill all the monsters in a map.
I'd like to make it an optional feature, and since making a menu option that gives a token item only works if it's done after loading a map, I figured that CVARS are my best bet for this purpose. I've never played around with Cvars much, so I'm a little lost on how I should do this in a "clean" way. Any advices?
Last edited by Grey-Wolf on Fri Jan 17, 2020 12:22 pm, edited 1 time in total.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Switchable menu option for a script

Post by Jarewill »

Might I ask what exactly do you mean by the "clean" way?

As for how to do it, let's start with a CVARINFO; that's where all the CVARs will be stored.
As for the menu option, MENUDEF is the way to do it.

Now, I had problems with MENUDEF the first time I tried it, so I'll post an example below:
Spoiler:
And in the ACS script, you will want to have this check:

Code: Select all

If(GetCVar("cvar_name")==1){insert code here}
Hope this helps.
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Switchable menu option for a script

Post by Grey-Wolf »

Jarewill wrote:Might I ask what exactly do you mean by the "clean" way?
"Clean" as in "without weird hacks and coded as a gentleman would", lol.
Grey-Wolf wrote:Hope this helps.
It did, thank you very much!
Post Reply

Return to “Scripting”