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

Logic branch: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Categorized)
 
(36 intermediate revisions by 19 users not shown)
Line 1: Line 1:
{{wrongtitle|title=logic_branch}}
{{LanguageBar}}
{{CD|CLogicBranch|file1=logicentities.cpp}}
{{this is a|logical entity|name=logic_branch|sprite=1}} It tests a [[boolean]] value and fires an [[output]] based on whether the value is true (one) or false (zero). Use this [[entity]] to branch between two potential sets of events.
{{note|Values greater than 1 are treated as 0.}}
__NOTOC__
== Keyvalues ==
{{KV Targetname}}
{{KV|Initial value|boolean|intn=InitialValue|Initial value for the boolean value (0 or 1).}}


==Entity Description==
== Inputs ==
'''Entity Name:''' logic_branch
{{I|SetValue|Set the boolean value without performing the comparison. Use this to hold a value for a future test.|param=bool}}
{{I|SetValueTest|Set the boolean value and test it, firing OnTrue or OnFalse based on the new value.|param=bool}}
{{I|Toggle|Toggle the boolean value between true and false.}}
{{I|ToggleTest|Toggle the boolean value and tests it, firing OnTrue or OnFalse based on the new value.}}
{{I|Test|Test the input value and fire OnTrue or OnFalse based on the value.}}


Tests a boolean value and fires an output based on whether the value is true or false. Use this entity to branch between two potential sets of events.
== Outputs ==
{{O|OnTrue|activator=activator of the input causing this to fire|This Output fires when the stored boolean value is true (1) and the Test input is fired ''or'' when the stored boolean value is set to true (1) by either the SetValueTest or ToggleTest inputs with parameter value 1.}}
{{O|OnFalse|activator=activator of the input causing this to fire|This Output fires when the stored boolean value is false (0) and the Test input is fired ''or'' when the stored boolean value is set to false (0) by either the SetValueTest or ToggleTest inputs with parameter value 0.}}


==Entity Values==
== See also ==
===Keys===
* {{ent|logic_branch_listener}}
* [[Logic gate]]


* '''Name''' ''targetname <target_source>'' 
[[Category:IO System]]
** The name that other entities refer to this entity by.
*'''Initial Value''' ''InitialValue <integer>''
** Initial value for the boolean value (0 or 1).
 
===Inputs===
 
* '''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.
* '''SetValue <bool>'''
** Set the boolean value without performing the comparison. Use this to hold a value for a future test.
* '''SetValueTest <bool>'''
** Set the boolean value and test it, firing OnTrue or OnFalse based on the new value.
* '''Toggle'''
** Toggle the boolean value between true and false.
* '''ToggleTest'''
** Toggle the boolean value and tests it, firing OnTrue or OnFalse based on the new value.
* '''Test'''
** Test the input value and fire OnTrue or OnFalse based on the value.
 
 
===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.
* '''OnTrue <bool>'''
** Fired when the input value is true (nonzero).
* '''OnFalse <bool>'''
** Fired when the input value is false (zero).
 
 
==Additional Info==
* Values greater than 1 are treated as 0.
 
[[Category:Entities]]

Latest revision as of 19:21, 30 April 2025

English (en)中文 (zh)Translate (Translate)
C++ Class hierarchy
CLogicBranch
CLogicalEntity
CServerOnlyEntity
CBaseEntity
C++ logicentities.cpp
Logic branch.png

logic_branch is a logical entity available in all Source Source games. It tests a boolean value and fires an output based on whether the value is true (one) or false (zero). Use this entity to branch between two potential sets of events.

Note.pngNote:Values greater than 1 are treated as 0.

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

Initial value (InitialValue) <boolean>
Initial value for the boolean value (0 or 1).

Inputs

SetValue <booleanRedirectInput/boolean>
Set the boolean value without performing the comparison. Use this to hold a value for a future test.
SetValueTest <booleanRedirectInput/boolean>
Set the boolean value and test it, firing OnTrue or OnFalse based on the new value.
Toggle
Toggle the boolean value between true and false.
ToggleTest
Toggle the boolean value and tests it, firing OnTrue or OnFalse based on the new value.
Test
Test the input value and fire OnTrue or OnFalse based on the value.

Outputs

OnTrue
!activator = activator of the input causing this to fire
!caller = this entity
This Output fires when the stored boolean value is true (1) and the Test input is fired or when the stored boolean value is set to true (1) by either the SetValueTest or ToggleTest inputs with parameter value 1.
OnFalse
!activator = activator of the input causing this to fire
!caller = this entity
This Output fires when the stored boolean value is false (0) and the Test input is fired or when the stored boolean value is set to false (0) by either the SetValueTest or ToggleTest inputs with parameter value 0.

See also