Math counter

From Valve Developer Community

This point-based entity is available in all Source games.

Table of contents

Entity description

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.

Image:note.png Note: Only stores integers


Keyvalues

Defines the name that other entities refer to this entity by.
  • hammerid [Episode Two Update]
<integer readonly> This id is used for debugging purposes in Hammer.
  • StartDisabled [Episode Two Update]
<boolean>
  • 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

  • Kill
Removes this entity from the world.
Removes this entity and all its children from the world.
  • AddOutput <string>
Evaluates a keyvalue/output on this entity. It can be potentially very dangerous, use with care.
Format: <key> <value>
Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire (-1 == infinite)>
Causes this entity's OnUser1-4 outputs to be fired. See User Inputs and Outputs.
  • Enable [Episode Two Update]
Enable this entity.
  • Disable [Episode Two Update]
Disable this entity.
  • Add <integer>
Adds the given value to the math_counter's value.
  • Subtract <integer>
Subtracts the given value from the math_counter's value.
  • 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.
  • GetValue [Episode Two Update]
Fires this entity's OnGetValue

Outputs

Fired in response to FireUser1-4 inputs. See User Inputs and Outputs.
!activator = activator
  • OutValue <integer>
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 SetValueNoFire is used.
  • OnHitMax
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
  • 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
  • OnGetValue <integer> [Episode Two Update]
Outputs integer value in this entity