dreamworkAPI
Ctrl K
GitHub
classDocs / console / Variable

console.Variable

classsharedmenusource
Object → console.Command → console.Variable

The console variable object.

Constructor

console.Variable(options: console.VariableOptions): console.Variable

Fields

NameTypeDescription
valueTThe value of the variable.
typeconsole.VariableTypeThe type of the variable (e.g., "int", "string").
namestringThe name of the variable.
descriptionstringThe description of the variable.
flagsintegerThe flags of the variable.
defaultTThe default value of the variable.
minT | nilThe minimum value of the variable (if applicable).
maxT | nilThe maximum value of the variable (if applicable).

Static functions

getGets a console.Variable object by its name.
getBooleanGets the value of the console.Variable object as a boolean.
getBoundsReturns the minimum and maximum values of the console.Variable object.
getDefaultGets the default value of the console.Variable object.
getDescriptionGets the help text of the console.Variable object.
getFlagsGets the flags of the console.Variable object.
getFloatGets the value of the console.Variable object as a float/double.
getIntegerGets the value of the console.Variable object as an integer.
getMaxGets the maximum value of the console.Variable object.
getMinGets the minimum value of the console.Variable object.
getStringGets the value of the console.Variable object as a string.
isFlagSetChecks if the flag is set on the console.Variable object.
revertReverts the value of the console.Variable object to its default value.
setSets the value of the console.Variable object.

#console.Variable.get

sharedmenunodiscardsource
function console.Variable.get(name: string, cvar_type: console.VariableType): console.Variable

Gets a console.Variable object by its name.

Parameters
NameTypeDescription
namestringThe name of the console variable.
cvar_typeconsole.VariableTypeThe type of the console variable.
Returns
TypeNameDescription
console.VariablevariableThe console.Variable object.
Overloads
function console.Variable.get(name: string, cvar_type: "boolean"): console.Variable<boolean>
function console.Variable.get(name: string, cvar_type: "integer"): console.Variable<integer>
function console.Variable.get(name: string, cvar_type: "number"): console.Variable<number>
function console.Variable.get(name: string, cvar_type: "string"): console.Variable<string>

#console.Variable.getBoolean

sharedmenunodiscardsource
function console.Variable.getBoolean(name: string): boolean

Gets the value of the console.Variable object as a boolean.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
booleanvalueThe value of the console.Variable object.

#console.Variable.getBounds

sharedmenunodiscardsource
function console.Variable.getBounds(name: string): number, number

Returns the minimum and maximum values of the console.Variable object.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
numberminimumThe minimum value of the console.Variable object.
numbermaximumThe maximum value of the console.Variable object.

#console.Variable.getDefault

sharedmenunodiscardsource
function console.Variable.getDefault(name: string): string

Gets the default value of the console.Variable object.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
stringdefaultThe default value of the console.Variable object.

#console.Variable.getDescription

sharedmenunodiscardsource
function console.Variable.getDescription(name: string): string

Gets the help text of the console.Variable object.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
stringhelpThe help text of the console.Variable object.

#console.Variable.getFlags

sharedmenunodiscardsource
function console.Variable.getFlags(name: string): integer

Gets the flags of the console.Variable object.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
integerflagsThe flags of the console.Variable object.

#console.Variable.getFloat

sharedmenunodiscardsource
function console.Variable.getFloat(name: string): number

Gets the value of the console.Variable object as a float/double.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
numbervalueThe value of the console.Variable object.

#console.Variable.getInteger

sharedmenunodiscardsource
function console.Variable.getInteger(name: string): integer

Gets the value of the console.Variable object as an integer.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
integervalueThe value of the console.Variable object.

#console.Variable.getMax

sharedmenunodiscardsource
function console.Variable.getMax(name: string): number

Gets the maximum value of the console.Variable object.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
numbermaximumThe maximum value of the console.Variable object.

#console.Variable.getMin

sharedmenunodiscardsource
function console.Variable.getMin(name: string): number

Gets the minimum value of the console.Variable object.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
numberminimumThe minimum value of the console.Variable object.

#console.Variable.getString

sharedmenunodiscardsource
function console.Variable.getString(name: string): string

Gets the value of the console.Variable object as a string.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
stringvalueThe value of the console.Variable object.

#console.Variable.isFlagSet

sharedmenunodiscardsource
function console.Variable.isFlagSet(name: string, flags: integer): boolean

Checks if the flag is set on the console.Variable object.

Parameters
NameTypeDescription
namestringThe name of the console variable.
flagsintegerThe flags to check.
Returns
TypeNameDescription
booleanis_settrue if the flag is set on the console.Variable object, false otherwise.

#console.Variable.revert

sharedmenusource
function console.Variable.revert(name: string): boolean

Reverts the value of the console.Variable object to its default value.

Parameters
NameTypeDescription
namestringThe name of the console variable.
Returns
TypeNameDescription
booleansuccesstrue if the value was set (or the command to set it was sent), false otherwise.

#console.Variable.set

sharedmenusource
function console.Variable.set(name: string, value: console.VariableValue): boolean

Sets the value of the console.Variable object.

Parameters
NameTypeDescription
namestringThe name of the console variable.
valueconsole.VariableValueThe value to set.
Returns
TypeNameDescription
booleansuccesstrue if the value was set (or the command to set it was sent), false otherwise.

Methods

attachAttaches a handler called on every change of the variable, attaching the same handler twice is a no-op.
awaitWaits for the console.Variable object to change.
clearRemoves every handler of the variable, pending handlers of a running change are skipped.
detachDetaches a handler previously passed to attach or once.
onceAttaches a one-shot handler, detached right before the next change calls it.
revertReverts the value of the console.Variable object to its default value.

#Variable:attach

sharedmenusource
function console.Variable:attach(handler: fun( variable: console.Variable<T>, value: T ) | Hook | Event)

Attaches a handler called on every change of the variable, attaching the same handler twice is a no-op.

Handlers run in protected mode, one failing handler is reported and never stops the others. While they run variable.value still holds the old value, the new one is passed as value.

Parameters
NameTypeDescription
handlerfun( variable: console.Variable<T>, value: T ) | Hook | EventThe callback or callable object.

#Variable:await

sharedmenuasyncsource
async function console.Variable:await(): console.Variable<T>, T

Waits for the console.Variable object to change.

Returns
TypeNameDescription
console.Variable<T>variable
Tnew_value

#Variable:clear

sharedmenusource
function console.Variable:clear()

Removes every handler of the variable, pending handlers of a running change are skipped.

#Variable:detach

sharedmenusource
function console.Variable:detach(handler: fun( variable: console.Variable<T>, value: T ) | Hook | Event): boolean

Detaches a handler previously passed to attach or once.

Parameters
NameTypeDescription
handlerfun( variable: console.Variable<T>, value: T ) | Hook | EventThe exact handler reference.
Returns
TypeNameDescription
booleanremovedtrue if the handler was attached.

#Variable:once

sharedmenusource
function console.Variable:once(handler: fun( variable: console.Variable<T>, value: T ) | Hook | Event)

Attaches a one-shot handler, detached right before the next change calls it.

Parameters
NameTypeDescription
handlerfun( variable: console.Variable<T>, value: T ) | Hook | EventThe callback or callable object.

#Variable:revert

sharedmenusource
function console.Variable:revert(): T

Reverts the value of the console.Variable object to its default value.

Returns
TypeNameDescription
TdefaultThe default value of the console.Variable object.

Inherited methods

From console.Command 2
Generated from the dreamwork meta branch.