This article's documentation is for anything that uses the Source engine. Click here for more information.

Toggle: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(create)
 
m (Replacing {{console command}}. This operation was performed by a bot.)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{ent|Toggle}} a <code>cvar</code> toggle it on or off, or cycle it between a set of values.
{{this is a|console command|name=toggle}}
'''Toggle''' a [[ConVar]] on and off, or cycle it between a set of values.


==Syntax==
==Syntax==
  toggle CVAR VALUE1 VALUE2 VALUE3 ... VALUEN
{{Code|toggle <cvar> <value 1> <value 2> <value 3> ...}}
"Toggling" past the last argument will loop around, ''i.e.'' cause the <code>cvar</code> to be set <code>VALUE1</code> once again. Repeating the last value will prevent looping.
 
"Toggling" past the last argument will loop around, ''i.e.'' the variable is set to its first value once again. Repeating the last value will prevent looping.
==Examples==
==Examples==
If values are omitted <code>cvar</code> is toggled between 0 and 1
If values are omitted, the cvar is toggled between 0 and 1
  toggle cl_showpos
 
Toggle 0 to 4 and stop at 4
{{Code|toggle cl_showpos}}
  toggle cl_showfps 0 1 2 3 4 4
 
Step 0 to 4
 
{{Code|toggle cl_showfps 0 1 2 3 4}}
 
Step 0 to 4 and stop at 4
 
{{Code|toggle cl_showfps 0 1 2 3 4 4}}
 
Cycle values
Cycle values
  toggle viewmodel_fov 54 57 59 65 71 98


[[Category:Console Commands]]
{{Code|toggle viewmodel_fov 54 57 59 65 71 98}}
==See also==
*{{ent|BindToggle}}
*{{ent|setinfo}}, create an arbitrary console variable.

Latest revision as of 18:01, 7 January 2024

toggle is a console command available in all Source Source games. Toggle a ConVar on and off, or cycle it between a set of values.

Syntax

toggle <cvar> <value 1> <value 2> <value 3> ...

"Toggling" past the last argument will loop around, i.e. the variable is set to its first value once again. Repeating the last value will prevent looping.

Examples

If values are omitted, the cvar is toggled between 0 and 1

toggle cl_showpos

Step 0 to 4

toggle cl_showfps 0 1 2 3 4

Step 0 to 4 and stop at 4

toggle cl_showfps 0 1 2 3 4 4

Cycle values

toggle viewmodel_fov 54 57 59 65 71 98

See also