> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: Console
icon: terminal
---

# <ApiPageIcon icon="terminal" />Console

<ApiExposes data="[{&#x22;k&#x22;:&#x22;NAMESPACE&#x22;,&#x22;c&#x22;:&#x22;fn&#x22;,&#x22;s&#x22;:&#x22;console&#x22;,&#x22;h&#x22;:&#x22;#console-1&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;console.Object&#x22;,&#x22;h&#x22;:&#x22;#consoleobject&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;console.Command&#x22;,&#x22;h&#x22;:&#x22;#consolecommand&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;console.CommandLine&#x22;,&#x22;h&#x22;:&#x22;#consolecommandline&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;console.Variable&#x22;,&#x22;h&#x22;:&#x22;#consolevariable&#x22;}]" />

<Heading level={2} id="console-1">
  console

  <ApiTag label="global table" />
</Heading>

Gives access to console variables and console commands by their names in the engine.
Indexing this table with a name returns one of three objects.

If a console variable with this name is registered, a `console.Variable` is returned.
Otherwise, if a console command with this name is registered, a `console.Command` is returned.
Otherwise, a `console.CommandLine` is returned. You can call it, but it is not an engine object.
Names are not case sensitive.

Every lookup returns an object, so you cannot check for `nil` to find out whether a name is
registered. Check the `is_valid` field instead.

`pairs(console)` goes over the registered variables and commands only. Each value it returns
is the engine object for that name.

Lookups are not cached. A `console.CommandLine` that you keep in a variable stays a
`console.CommandLine`. If a variable or command with that name is registered later, a new
lookup returns the new engine object.

<ApiMembers>
  <ApiMember kind="prop" name="console[string]" ret="[[{&#x22;s&#x22;:&#x22;console.Variable&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/console#consolevariable&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;console.Command&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/console#consolecommand&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;console.CommandLine&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/console#consolecommandline&#x22;}]]" />

  <ApiMember kind="fn" name="console.Execute" summary="Runs a command line in the client console. The arguments are converted to strings and joined with spaces, so `console.Execute(&#x22;buy&#x22;, &#x22;ak47&#x22;)` runs `buy ak47`. Calling a `console.CommandLine` does the same thing, with its name added at the start of the line." args="...?" sig="[{&#x22;s&#x22;:&#x22;console.Execute&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;The parts of the command line.&#x22;,&#x22;o&#x22;:true}]" />

  <ApiMember kind="type" name="console.ConVarType_t" summary="The data types that a console variable can have. The `type` field of `console.Variable` holds one of these values." ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]">
    <ApiEnum name="console.ConVarType_t" values="[[&#x22;INVALID&#x22;,&#x22;-1&#x22;,&#x22;&#x22;],[&#x22;BOOL&#x22;,&#x22;0&#x22;,&#x22;&#x22;],[&#x22;INT16&#x22;,&#x22;1&#x22;,&#x22;&#x22;],[&#x22;UINT16&#x22;,&#x22;2&#x22;,&#x22;&#x22;],[&#x22;INT32&#x22;,&#x22;3&#x22;,&#x22;&#x22;],[&#x22;UINT32&#x22;,&#x22;4&#x22;,&#x22;&#x22;],[&#x22;INT64&#x22;,&#x22;5&#x22;,&#x22;&#x22;],[&#x22;UINT64&#x22;,&#x22;6&#x22;,&#x22;&#x22;],[&#x22;FLOAT32&#x22;,&#x22;7&#x22;,&#x22;&#x22;],[&#x22;FLOAT64&#x22;,&#x22;8&#x22;,&#x22;&#x22;],[&#x22;UTLSTRING&#x22;,&#x22;9&#x22;,&#x22;&#x22;],[&#x22;COLOR&#x22;,&#x22;10&#x22;,&#x22;&#x22;],[&#x22;VECTOR2D&#x22;,&#x22;11&#x22;,&#x22;&#x22;],[&#x22;VECTOR3D&#x22;,&#x22;12&#x22;,&#x22;&#x22;],[&#x22;VECTOR4D&#x22;,&#x22;13&#x22;,&#x22;&#x22;],[&#x22;QANGLE&#x22;,&#x22;14&#x22;,&#x22;&#x22;],[&#x22;COUNT&#x22;,&#x22;15&#x22;,&#x22;&#x22;]]" />
  </ApiMember>

  <ApiMember kind="type" name="console.ConVarFlags_t" summary="The flag bits of a console variable or command, as found in the `flags` field of `console.Object`. Use `bit.band` to test them." ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]">
    <ApiEnum name="console.ConVarFlags_t" values="[[&#x22;NONE&#x22;,&#x22;0&#x22;,&#x22;&#x22;],[&#x22;LINKED_CONCOMMAND&#x22;,&#x22;1&#x22;,&#x22;&#x22;],[&#x22;DEVELOPMENTONLY&#x22;,&#x22;2&#x22;,&#x22;Hidden and locked outside development builds&#x22;],[&#x22;GAMEDLL&#x22;,&#x22;4&#x22;,&#x22;Defined by the server&#x22;],[&#x22;CLIENTDLL&#x22;,&#x22;8&#x22;,&#x22;Defined by the client&#x22;],[&#x22;HIDDEN&#x22;,&#x22;16&#x22;,&#x22;Hidden from listings and completion&#x22;],[&#x22;PROTECTED&#x22;,&#x22;32&#x22;,&#x22;Value is not sent to clients&#x22;],[&#x22;SPONLY&#x22;,&#x22;64&#x22;,&#x22;Single player only&#x22;],[&#x22;ARCHIVE&#x22;,&#x22;128&#x22;,&#x22;Saved to the config file&#x22;],[&#x22;NOTIFY&#x22;,&#x22;256&#x22;,&#x22;Changes are announced to players&#x22;],[&#x22;USERINFO&#x22;,&#x22;512&#x22;,&#x22;Sent to the server as user info&#x22;],[&#x22;PLACEHOLDER&#x22;,&#x22;1024&#x22;,&#x22;&#x22;],[&#x22;UNLOGGED&#x22;,&#x22;2048&#x22;,&#x22;&#x22;],[&#x22;IS_REGISTERING&#x22;,&#x22;4096&#x22;,&#x22;&#x22;],[&#x22;REPLICATED&#x22;,&#x22;8192&#x22;,&#x22;Server value is replicated to clients&#x22;],[&#x22;CHEAT&#x22;,&#x22;16384&#x22;,&#x22;Requires sv_cheats&#x22;],[&#x22;PER_USER&#x22;,&#x22;32768&#x22;,&#x22;&#x22;],[&#x22;DEMO&#x22;,&#x22;65536&#x22;,&#x22;Recorded into demos&#x22;],[&#x22;DONTRECORD&#x22;,&#x22;131072&#x22;,&#x22;Never recorded into demos&#x22;],[&#x22;CHANGE_CALLBACK_OCCURRING&#x22;,&#x22;262144&#x22;,&#x22;&#x22;],[&#x22;RELEASE&#x22;,&#x22;524288&#x22;,&#x22;Available in release builds&#x22;],[&#x22;MENUBAR_ITEM&#x22;,&#x22;1048576&#x22;,&#x22;&#x22;],[&#x22;SCRIPTABLE&#x22;,&#x22;2097152&#x22;,&#x22;&#x22;],[&#x22;NOT_CONNECTED&#x22;,&#x22;4194304&#x22;,&#x22;Cannot be changed while connected&#x22;],[&#x22;VCONSOLE_FUZZY_MATCHING&#x22;,&#x22;8388608&#x22;,&#x22;&#x22;],[&#x22;SERVER_CAN_EXECUTE&#x22;,&#x22;16777216&#x22;,&#x22;The server may run it on clients&#x22;],[&#x22;CLIENT_CAN_EXECUTE&#x22;,&#x22;33554432&#x22;,&#x22;Clients may run it&#x22;],[&#x22;SERVER_CANNOT_QUERY&#x22;,&#x22;67108864&#x22;,&#x22;The server cannot query the value&#x22;],[&#x22;VCONSOLE_SET_FOCUS&#x22;,&#x22;134217728&#x22;,&#x22;&#x22;],[&#x22;CLIENTCMD_CAN_EXECUTE&#x22;,&#x22;268435456&#x22;,&#x22;Client commands may run it&#x22;],[&#x22;EXECUTE_PER_TICK&#x22;,&#x22;536870912&#x22;,&#x22;&#x22;],[&#x22;DO_NOT_SNAPSHOT&#x22;,&#x22;1073741824&#x22;,&#x22;&#x22;],[&#x22;GC_TO_GC_SYNCHRONIZED&#x22;,&#x22;2147483648&#x22;,&#x22;&#x22;],[&#x22;DEVELOPMENTONLY_IMPLICIT&#x22;,&#x22;4294967296&#x22;,&#x22;&#x22;]]" />
  </ApiMember>
</ApiMembers>

## console.Object<ApiTag label="object type" />

The base class of console variables and console commands. All of its fields are read-only.

<ApiMembers>
  <ApiMember kind="prop" name="console.Object.flags" summary="The flag bits, as `console.ConVarFlags_t` values." ret="[[{&#x22;s&#x22;:&#x22;uint64_t&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#uint64_t&#x22;}]]" />

  <ApiMember kind="prop" name="console.Object.help" summary="The registered help text, or `nil` if there is no help text." ret="[[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="console.Object.info" summary="A pointer to the registration data of the object." ret="[[{&#x22;s&#x22;:&#x22;userdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#userdata&#x22;}]]" />

  <ApiMember kind="prop" name="console.Object.is_valid" summary="Whether the object refers to a valid engine object." ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}]]" />

  <ApiMember kind="prop" name="console.Object.name" summary="The registered name." ret="[[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}]]" />
</ApiMembers>

## console.Command<ApiTag label="object type · callable" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;console.Object&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/console#consoleobject&#x22;}]" />

A registered console command. When you call it, the registered callback of the command runs
directly. The arguments are converted to strings and passed to the command as its arguments,
so `console.buy("ak47")` runs `buy ak47`.

<ApiMembers>
  <ApiMember kind="ctor" name="console.Command(...)" syntax="console.Command(...?)" mm="__call" sig="[{&#x22;s&#x22;:&#x22;console.Command&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;o&#x22;:true}]" />
</ApiMembers>

## console.CommandLine<ApiTag label="object type · callable" />

A name that has no registered variable or command. When you call it, the line `name args...`
is run in the client console, so `console.drop()` does the same as `console.Execute("drop")`.
The arguments are converted to strings and joined with spaces. The engine decides whether the
line has any effect.

This class does not inherit from `console.Object`. It has no engine object, so it has no
`flags`, `info` or `help` fields.

<ApiMembers>
  <ApiMember kind="ctor" name="console.CommandLine(...)" syntax="console.CommandLine(...?)" mm="__call" sig="[{&#x22;s&#x22;:&#x22;console.CommandLine&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;o&#x22;:true}]" />

  <ApiMember kind="prop" name="console.CommandLine.is_valid" summary="Always `false`." ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}]]" />

  <ApiMember kind="prop" name="console.CommandLine.name" summary="The name that was looked up." ret="[[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}]]" />
</ApiMembers>

## console.Variable<ApiTag label="object type" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;console.Object&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/console#consoleobject&#x22;}]" />

A console variable, also called a ConVar.

<ApiMembers>
  <ApiMember kind="prop" name="console.Variable.default" summary="The default value of the variable. Read-only." ret="[[{&#x22;s&#x22;:&#x22;console.Variable.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/console#console-Variable-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="console.Variable.max" summary="The maximum value of the variable. Read-only." ret="[[{&#x22;s&#x22;:&#x22;console.Variable.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/console#console-Variable-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="console.Variable.min" summary="The minimum value of the variable. Read-only." ret="[[{&#x22;s&#x22;:&#x22;console.Variable.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/console#console-Variable-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="console.Variable.type" summary="The data type of the value, as a `console.ConVarType_t` value. Read-only." ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]" />

  <ApiMember kind="prop" name="console.Variable.value" summary="The current value of the variable. Its Lua type depends on the data type of the variable. You can assign a new value to this field." ret="[[{&#x22;s&#x22;:&#x22;console.Variable.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/console#console-Variable-Value&#x22;}]]" />

  <ApiMember kind="type" name="console.Variable.Value" summary="The Lua type of a console value depends on the registered type of the variable." ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;int64_t&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#int64_t&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;uint64_t&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#uint64_t&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;Color&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/color#color-1&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;Vector4D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector4d#vector4d&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;QAngle&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/angle#qangle&#x22;}]]" />
</ApiMembers>
