Incrementvar: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (clean)
(rewrote)
Line 1: Line 1:
A [[console command]] which can increment a given console variable.
'''<code>incrementvar</code>''' is a [[console command]] which can increment a given console variable. In tandem with {{ent|setinfo}}, it can be used to count things arbitrarily.


It increments the given ''varname'' by the ''delta'', whilst keeping the value within the bounds specified by ''minValue'' and ''maxValue''
==Syntax==
==Usage==
<pre>incrementvar CVAR MINVALUE MAXVALUE DELTA</pre>
{{syntax|incrementvar <varname> <minValue> <maxValue> <delta>}}
*CVAR: a console variable we want to change.
*MINVALUE: a minimum bound for our variable.
*MAXVALUE: a maximum bouns for our variable.
*DELTA: the amount to increase CVAR by. Set this to a negative number to ''decrement''.


There is a bug (or at least a weird way of doing things), where incrementing a variable past the maxValue specified can set it to 0. The example linked below avoids this problem by first decrementing, then incrementing the specified variable.
{{note|Incrementing a variable past the MAXVALUE specified causes the variable to loop around to the MINVALUE. The same happens the other way around, too.}}
 
==See Also==
*{{ent|BindToggle}}, a console command that works off this one.


See [[Unlocking chapters in your mod]] for an example of how to use incrementvar.
[[Category:Console Commands]]
[[Category:Console Commands]]

Revision as of 07:35, 14 July 2018

incrementvar is a console command which can increment a given console variable. In tandem with setinfo, it can be used to count things arbitrarily.

Syntax

incrementvar CVAR MINVALUE MAXVALUE DELTA
  • CVAR: a console variable we want to change.
  • MINVALUE: a minimum bound for our variable.
  • MAXVALUE: a maximum bouns for our variable.
  • DELTA: the amount to increase CVAR by. Set this to a negative number to decrement.
Note.pngNote:Incrementing a variable past the MAXVALUE specified causes the variable to loop around to the MINVALUE. The same happens the other way around, too.

See Also

  • BindToggle, a console command that works off this one.