Math counter: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (link)
(Cleanup and added new inputs / outputs)
Line 1: Line 1:
{{wrongtitle|title=math_counter}}
{{base point|math_counter}}
{{base_point}}


== Entity description ==
== Entity description ==
[[Image:{{PAGENAME}}.png|right]]
[[File:math_counter.png|left|link=]]
An [[entity]] that stores and manipulates an integer value. It can trigger on reaching user-defined maximum or minimum values, or output its value every time it changes. It also has the ability to perform simple mathematical functions.
An [[entity]] that stores and manipulates an integer value. It can trigger on reaching user-defined maximum or minimum values, or output its value every time it changes. It also has the ability to perform simple mathematical functions.
{{note|Only stores integers}}
{{note|Only stores integers.}}
* See also [[logic_case]]
{{clr}}
 
== See also ==
* [[logic_case]]
* [[func_movelinear]]
* [[func_movelinear]]
{{clr}}


== Keyvalues ==
== Keyvalues ==
* {{KV Targetname}}
{{KV|Initial Value|integer|Starting value for the counter.}}
 
{{KV|Minimum Legal Value|integer|Minimum legal value for the counter. If min{{=}}0 and max{{=}}0, no clamping is performed.}}
* '''{{EP2 add|StartDisabled}}'''
{{KV|Maximum Legal Value|integer|Maximum legal value for the counter. If min{{=}}0 and max{{=}}0, no clamping is performed.}}
: <[[boolean]]>
{{KV Targetname}}
 
{{KV EnableDisable}}
* '''startvalue'''
: <integer> The number the math_counter starts with.
 
* '''min'''
: <integer> Minimum legal value for the counter. If min and max are zero, no clamping is performed.
 
* '''max'''
: <integer> Maximum legal value for the counter. If min and max are zero, no clamping is performed.


== Inputs ==
== Inputs ==
* {{I Targetname}}
{{IO|Add|Add an amount to the counter and fire the OutValue output with the result.|param=integer}}
 
{{IO|Divide|Divide the counter by an amount and fire the OutValue output with the result.|param=integer}}
* '''{{EP2 add|Enable}}'''
{{IO|Multiply|Multiply the counter by an amount and fire the OutValue output with the result.|param=integer}}
: Enable this entity.
{{IO|SetValue|Set the counter to a new value and fire the OutValue output with the result.|param=integer}}
* '''{{EP2 add|Disable}}'''
{{IO|SetValueNoFire|Set the counter to a new value without firing any outputs.|param=integer}}
: Disable this entity.
{{IO|Subtract|Subtract an amount from the counter and fire the OutValue output with the result.|param=integer}}
 
{{IO|SetHitMax|Set the upper bound of the counter and fire the OutValue output with the current value.|param=integer}}
* '''Add <integer>'''
{{IO|SetHitMin|Set the lower bound of the counter and fire the OutValue output with the current value.|param=integer}}
: Adds the given value to the math_counter's value.
{{IO|GetValue|Causes the counter fire its OnGetValue output with the current value of the counter. Used for polling the counter when you don't want constant updates from the OutValue output.}}
 
{{IO|SetMaxValueNoFire|Set the MaxValue without firing any outputs.|param=integer|since=P2}}
* '''Subtract <integer>'''
{{IO|SetMinValueNoFire|Set the MinValue without firing any outputs.|param=integer|since=P2}}
: Subtracts the given value from the math_counter's value.
{{I Targetname}}
 
{{I EnableDisable}}
* '''Multiply <integer>'''
: Multiplies the the math_counter's value by the given value.
 
* '''Divide <integer>'''
: Divides the the math_counter's value by the given value.
 
* '''SetHitMax <integer>'''
: Changes the Maximum Legal Value to the given value.
 
* '''SetHitMin <integer>'''
: Changes the Minimum Legal Value to the given value.
 
* '''SetValue <integer>'''
: Changes the math_counter's value to the given value.
 
* '''SetValueNoFire <integer>'''
: Changes the math_counter's value to the given value, but doesn't update the change to any other entities.
 
* '''{{EP2 add|GetValue}}'''
: Fires this entity's OnGetValue


== Outputs ==
== Outputs ==
* {{O Targetname}}
{{IO|OutValue|Fired when the counter value changes.|param=integer}}
 
{{IO|OnHitMin|Fired when the counter value meets or goes below the min value. The counter must go back above the min value before the output will fire again.}}
* '''OutValue <integer>'''
{{IO|OnHitMax|Fired when the counter value meets or exceeds the max value. The counter must go below the max value before the output will fire again.}}
: Simply sends out the math_counter's value as though it were typed into the the parameter override field. Useful in conjunction with [[logic_case]] or [[func_movelinear]]. The change is outputed each time the value changes unless the <code>SetValueNoFire</code> is used.
{{IO|OnGetValue|Fired in response to the GetValue input. Used for polling the counter when you don't want constant updates from the OutValue output.|param=integer}}
 
{{IO|OnChangedFromMin|Fired when the counter value changes from the minimum value.|since=AS}}
* '''OnHitMax'''
{{IO|OnChangedFromMax|Fired when the counter value changes from the max value.|since=AS}}
: When the Maximum Legal Value is reach this output will be sent. In order to trigger it again you will need to alter the value first. {{activator|activator}}
{{O Targetname}}
 
* '''OnHitMin'''
: When the Minimum Legal Value is reach this output will be sent. In order to trigger it again you will need to alter the value first. {{activator|activator}}
 
* '''{{EP2 add|OnGetValue <integer>}}'''
: Outputs integer value in this entity

Revision as of 00:13, 9 June 2011

Template:Base point

Entity description

Math counter.png

An entity that stores and manipulates an integer value. It can trigger on reaching user-defined maximum or minimum values, or output its value every time it changes. It also has the ability to perform simple mathematical functions.

Note.pngNote:Only stores integers.

See also

Keyvalues

Initial Value ([todo internal name (i)]) <integer>
Starting value for the counter.
Minimum Legal Value ([todo internal name (i)]) <integer>
Minimum legal value for the counter. If min=0 and max=0, no clamping is performed.
Maximum Legal Value ([todo internal name (i)]) <integer>
Maximum legal value for the counter. If min=0 and max=0, no clamping is performed.
Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Start Disabled (StartDisabled) <boolean>
Stay dormant until activated (with theEnableinput).

Inputs

Add <integerRedirectInput/integer>
Add an amount to the counter and fire the OutValue output with the result.
Divide <integerRedirectInput/integer>
Divide the counter by an amount and fire the OutValue output with the result.
Multiply <integerRedirectInput/integer>
Multiply the counter by an amount and fire the OutValue output with the result.
SetValue <integerRedirectInput/integer>
Set the counter to a new value and fire the OutValue output with the result.
SetValueNoFire <integerRedirectInput/integer>
Set the counter to a new value without firing any outputs.
Subtract <integerRedirectInput/integer>
Subtract an amount from the counter and fire the OutValue output with the result.
SetHitMax <integerRedirectInput/integer>
Set the upper bound of the counter and fire the OutValue output with the current value.
SetHitMin <integerRedirectInput/integer>
Set the lower bound of the counter and fire the OutValue output with the current value.
GetValue
Causes the counter fire its OnGetValue output with the current value of the counter. Used for polling the counter when you don't want constant updates from the OutValue output.
SetMaxValueNoFire <integerRedirectInput/integer> (in all games since Portal 2)
Set the MaxValue without firing any outputs.
SetMinValueNoFire <integerRedirectInput/integer> (in all games since Portal 2)
Set the MinValue without firing any outputs.

EnableDisable:

Enable / Disable
Enable/disable this entity from performing its task. It might also disappear from view.

Outputs

OutValue <integerRedirectInput/integer>
Fired when the counter value changes.
OnHitMin
Fired when the counter value meets or goes below the min value. The counter must go back above the min value before the output will fire again.
OnHitMax
Fired when the counter value meets or exceeds the max value. The counter must go below the max value before the output will fire again.
OnGetValue <integerRedirectInput/integer>
Fired in response to the GetValue input. Used for polling the counter when you don't want constant updates from the OutValue output.
OnChangedFromMin  (in all games since Alien Swarm)
Fired when the counter value changes from the minimum value.
OnChangedFromMax  (in all games since Alien Swarm)
Fired when the counter value changes from the max value.