[ZScript] SetUserCvar

Moderator: GZDoom Developers

Post Reply
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

[ZScript] SetUserCvar

Post by Matt »

Seems kinda silly to still have to go back to ACS and make a script just to do this.
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: [ZScript] SetUserCvar

Post by gwHero »

Is already in:

Code: Select all

	CVar cl = CVar.FindCVar('cv_cloudspeed'); 
	cl.SetInt(40);
(see GZDoom.pk3 base.txt - CVar struct)

[UPDATE]
Or is this only for Server CVars.. ? Could be, in that case you're right (never tried that).
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: [ZScript] SetUserCvar

Post by Ed the Bat »

Just tried this, and it indeed works for user CVars.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: [ZScript] SetUserCvar

Post by Matt »

.......that is the most convoluted way I've seen to do anything all week. Reading the page on the CVar struct I see why it looks like that, I suppose.

EDIT: apparently the wiki page for it already exists, but it's not accessible from the main page about CVars. Added link.

(Also this page really needs updating) no it does not, that's the safest way to do it without the ZScript function phantombeta refers to below
Last edited by Matt on Wed Sep 27, 2017 4:37 pm, edited 1 time in total.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: [ZScript] SetUserCvar

Post by Matt »

This does not work for user cvars. It can't specify which user and will cause a desync.

Requesting that this feature suggestion be re-opened.


EDIT: no wait it does work... argh there are so many different variations on this I can't keep track at all
Last edited by Matt on Tue Sep 26, 2017 10:41 pm, edited 1 time in total.
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: [ZScript] SetUserCvar

Post by phantombeta »

That wiki page is outdated. Use the GetCVar static method, which takes in a PlayerInfo struct as its second argument.

Code: Select all

struct CVar native
{
    [...]
    native static CVar FindCVar(Name name);
    native static CVar GetCVar(Name name, PlayerInfo player = null);
    [...]
}
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: [ZScript] SetUserCvar

Post by Matt »

Now I'm even more confused by that "player = null" because I've been using GetCVar for players without defining the "player" argument and it's been working just fine o_O

EDIT: though I have been careful to make sure the caller was a playerpawn...


EDIT: Right, that's Actor [or Thinker or whatever].GetCVar I've been using, not this... thing.

Seriously GZDoom's CVar handling has a major nomenclature problem... why on earth wasn't this just named FindUserCVar???


EDIT:

> float
> cvar

... :shock:

Anyway, confirmed it works as advertised and does not desync.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”