Skip to main content

traceless.cvars

Lookup is table indexing: local cv = traceless.cvars["name"]. It returns Cvar userdata or nil when not found. Methods use colon calls and are not functions on the cvars table.

The userdata borrows a native cvar pointer without owning or keeping the manager alive. Use it while that native registration remains valid; there is no entity-style serial revalidation. Wrong userdata argument types raise Lua errors. Changes affect the native cvar and are not automatically reverted on script unload.

Cvar lookup​

traceless.cvars[name] resolves a string name to userdata or nil. The userdata metatable also uses __index to expose the methods below.

get_float​

cvar:get_float()

Returns: number; or nil.

Reads native float storage; missing cvar value returns nil.

get_int​

cvar:get_int()

Returns: integer; or nil.

Reads native int32 storage; missing cvar value returns nil.

get_string​

cvar:get_string()

Returns: string; or nil.

Reads native string storage; null value returns nil.

set_float​

cvar:set_float(value)

Returns: none.

Accepts a number, formats it, and routes through the cvar's normal SetString operation. Does nothing if its native cvar is absent.

set_int​

cvar:set_int(value)

Returns: none.

Accepts an integer, formats it, and uses SetString rather than a raw memory assignment.

set_string​

cvar:set_string(value)

Returns: none.

Uses the cvar's SetString operation with a string argument.

set_raw_float​

cvar:set_raw_float(value)

Returns: none.

Writes native float storage directly. Does not invoke normal setter conversion/callback behavior.

set_raw_int​

cvar:set_raw_int(value)

Returns: none.

Writes int32 storage directly. Does not invoke normal setter conversion/callback behavior.

invoke_callback​

cvar:invoke_callback(...)

Returns: none.

Concatenates arguments into a bounded text buffer and submits the cvar's client command name plus that text through the engine client. This is command execution, not direct invocation of an arbitrary native callback pointer. Missing cvar or engine is a no-op.

local traceless = require("traceless")
local cv = traceless.cvars["volume"]
if cv then traceless.console.info(cv:get_float()) end