Find
nil if the name isn’t registered. Case-insensitive.
cvar.viewmodel_fov does the same thing. Find, RestoreAll and the flag constants are real members of the table, so a convar sharing one of those names needs cvar.Find.
Lookups are cached and case-insensitive. Store frequently used convars in locals:
Get
vector2 and vector4 have no userdata type of their own, so they read back as plain keyed tables and are written the same way.
Set
Get, with basic conversions:
Vector and QAngle also accept plain tables. Color accepts a Color or packed 0xRRGGBBAA integer. Values are not clamped to cv.min or cv.max.
Two scripts can hold the same convar. The last one to Set it owns the restore, so unloading it puts the engine value back even if another script wrote it first.
Restore
RestoreAll restores every convar owned by the current script. Script unload and disable do this automatically.
Restore errors if another script owns the override, and does nothing if nobody does.
Properties
Read-only. Assigning to one errors; use
:Set.
Flags
FCVAR_CHEAT, FCVAR_REPLICATED, FCVAR_DEVELOPMENTONLY, FCVAR_REFERENCE, FCVAR_HIDDEN, FCVAR_PROTECTED, FCVAR_ARCHIVE, FCVAR_NOTIFY, FCVAR_USERINFO, FCVAR_PER_USER. For anything else test cv.flags against a literal.
Use HasFlag for flags above bit 31 because LuaJIT’s bit library is 32-bit.
Limits
Writes do not fire change callbacks. Server convars work only whenserver.dll is running locally.
For commands with no value behind them, use
engine.ExecuteCommand.