console.Variable
The console variable object.
Constructor
console.Variable(options: console.VariableOptions): console.Variable
Fields
| Name | Type | Description |
|---|
value | T | The value of the variable. |
type | console.VariableType | The type of the variable (e.g., "int", "string"). |
name | string | The name of the variable. |
description | string | The description of the variable. |
flags | integer | The flags of the variable. |
default | T | The default value of the variable. |
min | T | nil | The minimum value of the variable (if applicable). |
max | T | nil | The maximum value of the variable (if applicable). |
Static functions
get | Gets a console.Variable object by its name. |
getBoolean | Gets the value of the console.Variable object as a boolean. |
getBounds | Returns the minimum and maximum values of the console.Variable object. |
getDefault | Gets the default value of the console.Variable object. |
getDescription | Gets the help text of the console.Variable object. |
getFlags | Gets the flags of the console.Variable object. |
getFloat | Gets the value of the console.Variable object as a float/double. |
getInteger | Gets the value of the console.Variable object as an integer. |
getMax | Gets the maximum value of the console.Variable object. |
getMin | Gets the minimum value of the console.Variable object. |
getString | Gets the value of the console.Variable object as a string. |
isFlagSet | Checks if the flag is set on the console.Variable object. |
revert | Reverts the value of the console.Variable object to its default value. |
set | Sets the value of the console.Variable object. |
function console.Variable.get(name: string, cvar_type: console.VariableType): console.Variable
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
cvar_type | console.VariableType | The type of the console variable. |
Returns
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
function console.Variable.getBoolean(name: string): boolean
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
#console.Variable.getBounds
function console.Variable.getBounds(name: string): number, number
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
#console.Variable.getDefault
function console.Variable.getDefault(name: string): string
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
| Type | Name | Description |
|---|
string | default | The default value of the console.Variable object. |
#console.Variable.getDescription
function console.Variable.getDescription(name: string): string
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
#console.Variable.getFlags
function console.Variable.getFlags(name: string): integer
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
#console.Variable.getFloat
function console.Variable.getFloat(name: string): number
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
#console.Variable.getInteger
function console.Variable.getInteger(name: string): integer
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
function console.Variable.getMax(name: string): number
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
| Type | Name | Description |
|---|
number | maximum | The maximum value of the console.Variable object. |
function console.Variable.getMin(name: string): number
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
| Type | Name | Description |
|---|
number | minimum | The minimum value of the console.Variable object. |
#console.Variable.getString
function console.Variable.getString(name: string): string
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
#console.Variable.isFlagSet
function console.Variable.isFlagSet(name: string, flags: integer): boolean
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
flags | integer | The flags to check. |
Returns
| Type | Name | Description |
|---|
boolean | is_set | true if the flag is set on the console.Variable object, false otherwise. |
function console.Variable.revert(name: string): boolean
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
Returns
| Type | Name | Description |
|---|
boolean | success | true if the value was set (or the command to set it was sent), false otherwise. |
function console.Variable.set(name: string, value: console.VariableValue): boolean
Parameters
| Name | Type | Description |
|---|
name | string | The name of the console variable. |
value | console.VariableValue | The value to set. |
Returns
| Type | Name | Description |
|---|
boolean | success | true if the value was set (or the command to set it was sent), false otherwise. |
Methods
attach | Attaches a handler called on every change of the variable, attaching the same handler twice is a no-op. |
await | Waits for the console.Variable object to change. |
clear | Removes every handler of the variable, pending handlers of a running change are skipped. |
detach | Detaches a handler previously passed to attach or once. |
once | Attaches a one-shot handler, detached right before the next change calls it. |
revert | Reverts the value of the console.Variable object to its default value. |
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
function console.Variable:clear()
Removes every handler of the variable, pending handlers of a running change are skipped.
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
Returns
| Type | Name | Description |
|---|
boolean | removed | true if the handler was attached. |
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
function console.Variable:revert(): T
Returns
Inherited methods
From console.Command 2