[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.

[SOLVED]Switchable menu option for a script

Postby Grey-Wolf » Tue Jan 14, 2020 6:20 am

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.
User avatar
Grey-Wolf
 
Joined: 15 Jul 2018
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: Switchable menu option for a script

Postby Jarewill » Tue Jan 14, 2020 9:25 am

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 allExpand view
If(GetCVar("cvar_name")==1){insert code here}

Hope this helps.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Switchable menu option for a script

Postby Grey-Wolf » Wed Jan 15, 2020 7:23 am

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!
User avatar
Grey-Wolf
 
Joined: 15 Jul 2018
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia (Modern GZDoom)


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests