console
The console table gives access to game convars and console commands by name: console.sv_cheats, console.echo.
console.<name>#
| Parameter | Type | Description |
|---|---|---|
name |
string |
convar or command name |
Returns: convar if a convar with this name exists; otherwise command if a command exists; otherwise nil.
local sens = console.sensitivity
if sens then print(sens.name, " = ", sens.value) end
pairs(console)#
Iterates over all commands and convars: {name = command}, then {name = convar}.
Returns: a pairs iterator.
local n = 0
for name, obj in pairs(console) do n = n + 1 end
print("Commands and convars: ", n)
The convar object#
Read-only: assigning fields changes nothing and gives no error.
| Field | Type | Description |
|---|---|---|
name |
string |
name |
help |
string |
description |
flags |
64-bit integer | FCVAR_* flags |
info |
lightuserdata |
pointer to the convar data |
is_valid |
boolean |
the convar is registered |
type |
number |
value type (table below) |
value |
depends on the type | current value |
type |
Value | type |
Value |
|---|---|---|---|
| 0 | boolean |
7, 8 | number (float, double) |
| 1–4 | number (int16, uint16, int32, uint32) |
9 | string |
| 5, 6 | 64-bit integer (int64, uint64) | 10 | color |
| 11 | vector2 |
12 | vector |
| 14 | angle |
local c = console.sv_cheats
if c and c.is_valid then
print("sv_cheats = ", c.value) -- boolean
end
The command object#
| Field | Type | Description |
|---|---|---|
name |
string |
command name |
help |
string |
description |
flags |
64-bit integer | flags |
info |
lightuserdata |
command data |
is_valid |
boolean |
the command is valid |
command(...)#
Runs the command directly, bypassing the console queue. Each argument becomes a separate word of the command (converted to a string as in print).
| Parameter | Type | Description |
|---|---|---|
... |
any |
command arguments |
Returns: nothing.
console.echo("[script] hello", 1, true)