Math counter (Source 2): Difference between revisions
Jump to navigation
Jump to search

Note:If this causes a division by zero, the counter will ignore the input.
m (Include missing inputs and outputs accessible by every Source 2 entity) |
No edit summary |
||
| Line 1: | Line 1: | ||
{{tabs|main=source|source=1|source2=1|math_counter}} | {{tabs|main=source|source=1|source2=1|math_counter}} | ||
{{this is a|point entity|sprite=1|name=math_counter|engine=Source 2}} 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. | {{this is a|point entity|sprite=1|name=math_counter|engine=Source 2}} 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. | ||
| Line 11: | Line 10: | ||
== Inputs == | == Inputs == | ||
{{ | {{I|Add|Add an amount to the counter and fire the <code>OutValue</code> output with the result.|param=integer}} | ||
{{ | {{I|Divide|Divide the counter by an amount and fire the <code>OutValue</code> output with the result.|param=integer}} | ||
{{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.}} | ||
{{ | {{I|Multiply|Multiply the counter by an amount and fire the <code>OutValue</code> output with the result.|param=integer}} | ||
{{ | {{I|SetValue|Set the counter to a new value and fire the <code>OutValue</code> output with the result.|param=integer}} | ||
{{ | {{I|SetValueNoFire|Set the counter to a new value without firing any outputs.|param=integer}} | ||
{{ | {{I|Subtract|Subtract an amount from the counter and fire the <code>OutValue</code> output with the result.|param=integer}} | ||
{{ | {{I|SetHitMax|Set the upper bound of the counter and fire the <code>OutValue</code> output with the current value.|param=integer}} | ||
{{ | {{I|SetHitMin|Set the lower bound of the counter and fire the <code>OutValue</code> output with the current value.|param=integer}} | ||
{{ | {{I|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.}} | ||
{{I EnableDisable}} | {{I EnableDisable}} | ||
== Outputs == | == Outputs == | ||
{{ | {{O|OutValue|Fired when the counter value changes.<br>If the Target Input's parameters is left empty, the math_counter's value is used. {{tip|Useful for entities such as: {{ent|logic_case}},{{ent|math_remap}},{{ent|logic_compare}}.}}|param=integer}} | ||
{{ | {{O|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.}} | ||
{{ | {{O|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.}} | ||
{{ | {{O|OnGetValue|Fired in response to the <code>GetValue</code> input; used when you don't want constant updates from the <code>OutValue</code> output.<br>If the Target Input's parameters is left empty, the math_counter's value is used. {{tip|Useful for entities such as: {{ent|logic_case}},{{ent|math_remap}},{{ent|logic_compare}}.}} |param=integer}} | ||
{{ | {{O|OnChangedFromMin|Fired when the counter value changes from the minimum value.}} | ||
{{ | {{O|OnChangedFromMax|Fired when the counter value changes from the max value.}} | ||
== See also == | == See also == | ||
* [[logic_case]] | * [[logic_case]] | ||
* [[math_remap]] | * [[math_remap]] | ||
Revision as of 11:08, 26 September 2024

math_counter is a point entity available in all
Source 2 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
- Name (targetname) <string>[ Edit ]
- The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g.
parentnameortarget).
Also displayed in Hammer's 2D views and Entity Report.See also: Generic Keyvalues, Inputs and Outputs available to all entities
- Initial Value (startvalue) <integer>
- Starting value for the counter.
- Minimum Legal Value (min) <integer>
- Minimum legal value for the counter. If min=0 and max=0, no clamping is performed.
- Maximum Legal Value (max) <integer>
- Maximum legal value for the counter. If min=0 and max=0, no clamping is performed.
- Start Disabled (StartDisabled) <boolean>
- Stay dormant until activated (with the
Enableinput).
Inputs
- Add <integer>
- Add an amount to the counter and fire the
OutValueoutput with the result.
- Divide <integer>
- Divide the counter by an amount and fire the
OutValueoutput with the result.
- Multiply <integer>
- Multiply the counter by an amount and fire the
OutValueoutput with the result.
- SetValue <integer>
- Set the counter to a new value and fire the
OutValueoutput with the result.
- SetValueNoFire <integer>
- Set the counter to a new value without firing any outputs.
- Subtract <integer>
- Subtract an amount from the counter and fire the
OutValueoutput with the result.
- SetHitMax <integer>
- Set the upper bound of the counter and fire the
OutValueoutput with the current value.
- SetHitMin <integer>
- Set the lower bound of the counter and fire the
OutValueoutput with the current value.
- GetValue
- Causes the counter to fire its
OnGetValueoutput with the current value of the counter. Used for polling the counter when you don't want constant updates from theOutValueoutput.
EnableDisable:
- Enable / Disable
- Enable/disable this entity from performing its task. It might also disappear from view.
Outputs
- OutValue <integer>
- Fired when the counter value changes.
If the Target Input's parameters is left empty, the math_counter's value is used.
Tip: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 <integer>
- Fired in response to the
GetValueinput; used when you don't want constant updates from theOutValueoutput.
If the Target Input's parameters is left empty, the math_counter's value is used.
Tip:Useful for entities such as: logic_case,math_remap,logic_compare.
- OnChangedFromMin
- Fired when the counter value changes from the minimum value.
- OnChangedFromMax
- Fired when the counter value changes from the max value.