cvar
A table letting you get and set the value of cvars and invoke their callbacks. Uses Object-oriented format
cvar_object:get_float()
: numberReturns nil if called on a ConCommand.
cvar_object:get_int()
: numberReturns nil if called on a ConCommand.
cvar_object:get_string()
: stringReturns nil on failure.
cvar_object:invoke_callback(...)
Argument | Type | Description |
---|---|---|
... | | Arguments passed to the callback |
Executes a ConCommand or cvar callback, passing its arguments to it
cvar_object:set_float(value: number)
Argument | Type | Description |
---|---|---|
value | number (float) | Float value |
Sets the int, float and string value to the passed float. Invokes the change callback
cvar_object:set_int(value: number)
Argument | Type | Description |
---|---|---|
value | number (integer) | Integer value |
Sets the int, float and string value to the passed float. Invokes the change callback
cvar_object:set_raw_float(value: number)
Argument | Type | Description |
---|---|---|
value | number (float) | Float value |
This sets the float value without changing the integer and string values.
cvar_object:set_raw_int(value: number)
Argument | Type | Description |
---|---|---|
value | number (integer) | Integer value |
This sets the integer value without changing the float and string values.
cvar_object:set_string(value: string)
Argument | Type | Description |
---|---|---|
value | string | String value |
Sets the int, float and string value to the passed float. Invokes the change callback
local bxor = bit.bxor
local cl_fullupdate = cvar.cl_fullupdate
local developer = cvar.developer
-- invoking callback of ConCommand
cl_fullupdate:invoke_callback()
-- toggle ConVar
local oldval = developer.get_int()
developer:set_raw_int(bxor(oldval, 1))
local snd_setmixer = cvar.snd_setmixer
-- Mutes ambient volume by setting the mixer "vol" option to 0
snd_setmixer:invoke_callback("Ambient", "vol", "0")
Last modified 1yr ago