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

Logic timer: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Almost overwrote a previous edit. Timing is everything. :))
 
(57 intermediate revisions by 27 users not shown)
Line 1: Line 1:
{{wrongtitle|title=logic_timer}}
{{LanguageBar}}
{{TabsBar|main=s2|base=logic_timer}}
{{CD|CTimerEntity|base=CLogicalEntity|file1=logicentities.cpp}}
{{This is a|logical entity|name=logic_timer|sprite=1}} fires an [[output]] at regular or random intervals. It can optionally alternate between a "high" and a "low" output.
{{Tip|Use with {{ent|logic_case}} for extremely random events.}}


==Entity Description==
== Keyvalues ==
'''Entity Name:''' logic_timer
{{KV Targetname}}
{{KV|Use Random Time|intn=UseRandomTime|boolean|Makes the entity fire at random intervals. Range of values is restricted by the next two KVs. }}
{{KV|Minimum Random Interval|intn=LowerRandomBound|float|If "Use Random Time" is set, this is the minimum time between timer fires. The time will be a random number between this and the "Maximum Random Interval".}}
{{KV|Maximum Random Interval|intn=UpperRandomBound|float|If "Use Random Time" is set, this is the maximum time between timer fires. The time will be a random number between the "Minimum Random Interval" and this.}}
{{KV|Refire Interval|intn=RefireTime|float|If "Use Random Time" isn't set, this is the time between timer fires, in seconds. Make sure output delay times are less than this value.}}
{{KV StartDisabled}}


An entity that fires a timer event at regular, or random, intervals. It can also be set to oscillate betweena high and low end, in which case it will fire alternating high/low outputs each time it fires.
== Flags ==
{{fl|1|Oscillator|(alternates between <code>OnTimerHigh</code> and <code>OnTimerLow</code> outputs)}}
{{tip|It will start with <code>OnTimerLow</code>, and all the odd-numbered refires will be <code>OnTimerLow</code>.}}


==Entity Values==
== Inputs ==
===Keys===
{{I|RefireTime|Set a new Refire Interval.|param=float}}
{{I|ResetTimer|Reset the timer. It will fire after the Refire Interval expires.}}
{{I|FireTimer|Force the timer to fire immediately.}}
{{I|Enable|Enable the timer. {{Note|Enabling the entity resets its timer.}}}}
{{I|Disable|Disable the timer.}}
{{I|Toggle|Toggle the timer on/off.}}
{{I|LowerRandomBound|Set a new Minimum Random Interval.|param=float}}
{{I|UpperRandomBound|Set a new Maximum Random Interval.|param=float}}
{{I|AddToTimer|Add time to the timer if it is currently enabled.  Does not change the Refire Interval.|param=float}}
{{I|SubtractFromTimer|Subtract time from the timer if it is currently enabled.  Does not change the Refire Interval.|param=float}}
{{I|UseRandomTime|0 or 1, whether random time is enabled. If random time starts enabled and gets disabled here, the refire interval is set to the Maximum Random Interval.|nofgd=1}}


* '''Name''' ''targetname <target_source>'' 
== Outputs ==
** The name that other entities refer to this entity by.
{{O|OnTimer|Fired when the timer expires.}}
* '''Start Disabled''' ''StartDisabled <choices>''
{{O|OnTimerHigh|Fired every other time for an oscillating timer.}}
** If '''Yes''', this entity starts disabled.
{{O|OnTimerLow|Fired every other time for an oscillating timer.}}
* '''Use Random Time''' ''UseRandomTime <choices>''
** If '''Yes''', fires randomly at an interval from the last trigger.
* '''Minimum Random Interval''' ''LowerRandomBound <string>''
** If 'Use Random Time' is set, this is the minimum time between timer fires. The time will be a random number between this and the 'Maximum Random Interval'.
* '''Maximum Random Interval''' ''UpperRandomBound <string>''
** If 'Use Random Time' is set, this is the maximum time between timer fires. The time will be a random number between the 'Minimum Random Interval' and this.
* '''Refire Interval''' ''RefireTime <string>''
** If 'Use Random Time' isn't set, this is the time between timer fires, in seconds.


== See also ==
* {{ent|logic_case}}
* [[Left 4 Dead 2/Script Functions/AddThinkToEnt]]


===Inputs===
[[Category:IO System]]
 
* '''Kill'''
** Removes this entity from the world.
* '''KillHierarchy''' 
** Removes this entity and all its children from the world.
* '''AddOutput''' ''<output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire (-1 == infinite)>''
** Adds an entity I/O connection to this entity. Very dangerous, use with care
* '''FireUser1'''
** Causes this entity's OnUser1 output to be fired.
* '''FireUser2'''
** Causes this entity's OnUser2 output to be fired.
* '''FireUser3'''
** Causes this entity's OnUser3 output to be fired.
* '''FireUser4'''
** Causes this entity's OnUser4 output to be fired.
* '''Enable'''
** Enable this entity.
* '''Disable'''
** Disable this entity.
* '''RefireTime <integer>'''
** Set a new Refire Interval.
* '''FireTimer'''
** Force the timer to fire immediately.
* '''Enable'''
** Enable the timer.
* '''Disable'''
** Disable the timer.
* '''Toggle'''
** Toggle the timer on/off.
* '''LowerRandomBound <float>'''
** Set a new Minimum Random Interval.
* '''UpperRandomBound <float>'''
** Set a new Maximum Random Interval.
 
 
===Outputs===
 
* '''OnUser1'''
** Fired in response to FireUser1 input.
* '''OnUser2'''
** Fired in response to FireUser2 input.
* '''OnUser3'''
** Fired in response to FireUser3 input.
* '''OnUser4'''
** Fired in response to FireUser4 input.
* '''OnTimer'''
** Fired when the timer expires.
* '''OnTimerHigh'''
** Fired every other time for an oscillating timer.
* '''OnTimerLow'''
** Fired every other time for an oscillating timer.
 
 
===Flags===
 
* '''Oscillator (alternates between OnTimerHigh and OnTimerLow outputs)''' (Default Unchecked)
** Self-explanatory.
 
 
==Additional Info==
* An oscillator's first output will be an OnTimerHigh output.
* Use with [[Logic_case]] for extremely random events.
* Could be used to deploy [[env_headcrabcanister]]s at random intervals, instead of using fixed delays on the inputs.
 
[[Category:Entities]]

Latest revision as of 06:47, 4 June 2025

English (en)Русский (ru)中文 (zh)Translate (Translate)
C++ Class hierarchy
CTimerEntity
CLogicalEntity
CServerOnlyEntity
CBaseEntity
C++ logicentities.cpp
Logic timer.png

logic_timer is a logical entity available in all Source Source games. fires an output at regular or random intervals. It can optionally alternate between a "high" and a "low" output.

Tip.pngTip:Use with logic_case for extremely random events.

Keyvalues

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

Use Random Time (UseRandomTime) <boolean>
Makes the entity fire at random intervals. Range of values is restricted by the next two KVs.
Minimum Random Interval (LowerRandomBound) <float>
If "Use Random Time" is set, this is the minimum time between timer fires. The time will be a random number between this and the "Maximum Random Interval".
Maximum Random Interval (UpperRandomBound) <float>
If "Use Random Time" is set, this is the maximum time between timer fires. The time will be a random number between the "Minimum Random Interval" and this.
Refire Interval (RefireTime) <float>
If "Use Random Time" isn't set, this is the time between timer fires, in seconds. Make sure output delay times are less than this value.
Start Disabled (StartDisabled) <boolean>
Stay dormant until activated (with theEnableinput).

Flags

Oscillator : [1]
(alternates between OnTimerHigh and OnTimerLow outputs)
Tip.pngTip:It will start with OnTimerLow, and all the odd-numbered refires will be OnTimerLow.

Inputs

RefireTime <floatRedirectInput/float>
Set a new Refire Interval.
ResetTimer
Reset the timer. It will fire after the Refire Interval expires.
FireTimer
Force the timer to fire immediately.
Enable
Enable the timer.
Note.pngNote:Enabling the entity resets its timer.
Disable
Disable the timer.
Toggle
Toggle the timer on/off.
LowerRandomBound <floatRedirectInput/float>
Set a new Minimum Random Interval.
UpperRandomBound <floatRedirectInput/float>
Set a new Maximum Random Interval.
AddToTimer <floatRedirectInput/float>
Add time to the timer if it is currently enabled. Does not change the Refire Interval.
SubtractFromTimer <floatRedirectInput/float>
Subtract time from the timer if it is currently enabled. Does not change the Refire Interval.
UseRandomTime  !FGD
0 or 1, whether random time is enabled. If random time starts enabled and gets disabled here, the refire interval is set to the Maximum Random Interval.

Outputs

OnTimer
Fired when the timer expires.
OnTimerHigh
Fired every other time for an oscillating timer.
OnTimerLow
Fired every other time for an oscillating timer.

See also