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

math_counter

From Valve Developer Community
Jump to: navigation, search
class hierarchy
CMathCounter defined in logicentities.cpp
CLogicalEntity
CServerOnlyEntity
CBaseEntity
Math counter.png

math_counter is a point entity available in all Source Source games. It stores and manipulates a numerical 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. When the math_counter is disabled, it will become read-only until re-enabled.

Keyvalues


Targetname:
Name (targetname) <string>
The targetname that other entities refer to this entity by.
Initial Value (startvalue) <float>
Starting value for the counter.
Icon-Bug.pngBug:When the entity is created at run-time, this value is converted to an integer and will be rounded off!
PlacementTip.pngWorkaround: Set the initial value at run-time using the entity's SetValue input. For example, from a logic_relay using its OnSpawn output.
Minimum Legal Value (min) <float>
Minimum legal value for the counter. If min=0 and max=0, no clamping is performed.
Maximum Legal Value (max) <float>
Maximum legal value for the counter. If min=0 and max=0, no clamping is performed.

EnableDisable:

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

Inputs

Add <float>
Add an amount to the counter and fire the OutValue output with the result.
Divide <float>
Divide the counter by an amount and fire the OutValue output with the result.
Note.pngNote:If this causes a division by zero, the counter will ignore the input.
Multiply <float>
Multiply the counter by an amount and fire the OutValue output with the result.
SetValue <float>
Set the counter to a new value and fire the OutValue output with the result.
SetValueNoFire <float>
Set the counter to a new value without firing any outputs.
Subtract <float>
Subtract an amount from the counter and fire the OutValue output with the result.
SetHitMax <float>
Set the upper bound of the counter and fire the OutValue output with the current value.
SetHitMin <float>
Set the lower bound of the counter and fire the OutValue output with the current value.
GetValue
Causes the counter to 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 <float> (in all games since Portal 2)
Set the counter to the MaxValue without firing any outputs.
SetMinValueNoFire <float> (in all games since Portal 2)
Set the counter to 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 <float>
Fired when the counter value changes.
If the Target Input's parameters is left empty, the math_counter's value is used.
Tip.pngTip:Useful for entities such as: logic_case,math_remap,logic_compare.
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 <float>
Fired in response to the GetValue input; used when you don't want constant updates from the OutValue output.
If the Target Input's parameters is left empty, the math_counter's value is used.
Tip.pngTip:Useful for entities such as: logic_case,math_remap,logic_compare.
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.

See also