Math counter: Difference between revisions
Jump to navigation
Jump to search
Note:If this causes a division by zero, the counter will ignore the input.
Note:Generates the value of the math_counter into the parameters section of an Output Statement. To use a generated parameter, just leave the field reading <none>.
Tip:Useful in tandem with logic_case and logic_compare
Note:Generates the value of the math_counter into the parameters section of an Output Statement. To use a generated parameter, just leave the field reading <none>.
Tip:Useful in tandem with logic_case, math_remap and logic_compare.
m (→Outputs) |
TeamSpen210 (talk | contribs) (Counters use and input/output floating point values, not integers.) |
||
Line 1: | Line 1: | ||
{{base point|math_counter|sprite=1}} 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. | {{base point|math_counter|sprite=1}} 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. | ||
{{code class|CMathCounter|logicentities.cpp}} | |||
{{clr}} | {{clr}} | ||
Line 8: | Line 11: | ||
== Keyvalues == | == Keyvalues == | ||
{{KV|Initial Value| | {{KV|Initial Value (startvalue)|float|Starting value for the counter.}} | ||
{{KV|Minimum Legal Value| | {{KV|Minimum Legal Value (min)|float|Minimum legal value for the counter. If min{{=}}0 and max{{=}}0, no clamping is performed.}} | ||
{{KV|Maximum Legal Value| | {{KV|Maximum Legal Value (max)|float|Maximum legal value for the counter. If min{{=}}0 and max{{=}}0, no clamping is performed.}} | ||
{{KV Targetname}} | {{KV Targetname}} | ||
{{KV EnableDisable}} | {{KV EnableDisable}} | ||
== Inputs == | == Inputs == | ||
{{IO|Add|Add an amount to the counter and fire the <code>OutValue</code> output with the result.|param= | {{IO|Add|Add an amount to the counter and fire the <code>OutValue</code> output with the result.|param=float}} | ||
{{IO|Divide|Divide the counter by an amount and fire the <code>OutValue</code> output with the result.|param= | {{IO|Divide|Divide the counter by an amount and fire the <code>OutValue</code> output with the result.|param=float}} | ||
{{note|If this causes a division by zero, the counter will ignore the input.}} | {{note|If this causes a division by zero, the counter will ignore the input.}} | ||
{{IO|Multiply|Multiply the counter by an amount and fire the <code>OutValue</code> output with the result.|param= | {{IO|Multiply|Multiply the counter by an amount and fire the <code>OutValue</code> output with the result.|param=float}} | ||
{{IO|SetValue|Set the counter to a new value and fire the <code>OutValue</code> output with the result.|param= | {{IO|SetValue|Set the counter to a new value and fire the <code>OutValue</code> output with the result.|param=float}} | ||
{{IO|SetValueNoFire|Set the counter to a new value without firing any outputs.|param=integer}} | {{IO|SetValueNoFire|Set the counter to a new value without firing any outputs.|param=integer}} | ||
{{IO|Subtract|Subtract an amount from the counter and fire the <code>OutValue</code> output with the result.|param= | {{IO|Subtract|Subtract an amount from the counter and fire the <code>OutValue</code> output with the result.|param=float}} | ||
{{IO|SetHitMax|Set the upper bound of the counter and fire the <code>OutValue</code> output with the current value.|param= | {{IO|SetHitMax|Set the upper bound of the counter and fire the <code>OutValue</code> output with the current value.|param=float}} | ||
{{IO|SetHitMin|Set the lower bound of the counter and fire the <code>OutValue</code> output with the current value.|param= | {{IO|SetHitMin|Set the lower bound of the counter and fire the <code>OutValue</code> output with the current value.|param=float}} | ||
{{IO|GetValue|Causes the counter fire its <code>OnGetValue</code> output with the current value of the counter. Used for polling the counter when you don't want constant updates from the <code>OutValue</code> output.}} | {{IO|GetValue|Causes the counter to fire its <code>OnGetValue</code> output with the current value of the counter. Used for polling the counter when you don't want constant updates from the <code>OutValue</code> output.}} | ||
{{IO|SetMaxValueNoFire|Set the MaxValue without firing any outputs.|param= | {{IO|SetMaxValueNoFire|Set the counter to the MaxValue without firing any outputs.|param=float|since=P2}} | ||
{{IO|SetMinValueNoFire|Set the MinValue without firing any outputs.|param= | {{IO|SetMinValueNoFire|Set the counter to the MinValue without firing any outputs.|param=float|since=P2}} | ||
{{I Targetname}} | {{I Targetname}} | ||
{{I EnableDisable}} | {{I EnableDisable}} | ||
== Outputs == | == Outputs == | ||
{{IO|OutValue|Fired when the counter value changes.|param= | {{IO|OutValue|Fired when the counter value changes.|param=float}} | ||
{{note|Generates the value of the [[math_counter]] into the parameters section of an Output Statement. To use a generated parameter, just leave the field reading <none>.}} | {{note|Generates the value of the [[math_counter]] into the parameters section of an Output Statement. To use a generated parameter, just leave the field reading <none>.}} | ||
{{tip|Useful in tandem with [[logic_case]] and [[logic_compare]]}} | {{tip|Useful in tandem with [[logic_case]] and [[logic_compare]]}} | ||
{{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.}} | {{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.}} | ||
{{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.}} | {{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.}} | ||
{{IO|OnGetValue|Fired in response to the <code>GetValue</code> input. Used for polling the counter when you don't want constant updates from the <code>OutValue</code> output.|param= | {{IO|OnGetValue|Fired in response to the <code>GetValue</code> input. Used for polling the counter when you don't want constant updates from the <code>OutValue</code> output.|param=float}} | ||
{{note|Generates the value of the [[math_counter]] into the parameters section of an Output Statement. To use a generated parameter, just leave the field reading <none>.}} | {{note|Generates the value of the [[math_counter]] into the parameters section of an Output Statement. To use a generated parameter, just leave the field reading <none>.}} | ||
{{tip|Useful in tandem with [[logic_case]] and [[logic_compare]]}} | {{tip|Useful in tandem with [[logic_case]], [[math_remap]] and [[logic_compare]].}} | ||
{{IO|OnChangedFromMin|Fired when the counter value changes from the minimum value.|since=AS}} | {{IO|OnChangedFromMin|Fired when the counter value changes from the minimum value.|since=AS}} | ||
{{IO|OnChangedFromMax|Fired when the counter value changes from the max value.|since=AS}} | {{IO|OnChangedFromMax|Fired when the counter value changes from the max value.|since=AS}} | ||
{{O Targetname}} | {{O Targetname}} |
Revision as of 01:11, 12 September 2018
Template:Base point 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.
See also
Keyvalues
- Minimum Legal Value (min) ([todo internal name (i)]) <float>
- Minimum legal value for the counter. If min=0 and max=0, no clamping is performed.
- Maximum Legal Value (max) ([todo internal name (i)]) <float>
- 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
ortarget
).
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 the
Enable
input).
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.

- 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 <integer >
- 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 theOutValue
output.
- SetMaxValueNoFire <float > (in all games since
)
- Set the counter to the MaxValue without firing any outputs.
- SetMinValueNoFire <float > (in all games since
)
- 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.


- 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 for polling the counter when you don't want constant updates from theOutValue
output.


- OnChangedFromMin (in all games since
)
- Fired when the counter value changes from the minimum value.
- OnChangedFromMax (in all games since
)
- Fired when the counter value changes from the max value.