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

Logic compare: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Categorized)
No edit summary
 
(32 intermediate revisions by 22 users not shown)
Line 1: Line 1:
{{wrongtitle|title=logic_compare}}
{{Underlinked|date=January 2024}}
{{LanguageBar}}
[[File:logic_compare.png|left]]
{{CD|CLogicCompare|file1=logicentities.cpp}}
{{this is a|logical entity|name=logic_compare}} It examines the relationship between two numbers ("value" and "compare value"), and fires appropriate [[#Outputs|output]](s).


==Entity Description==
The equation is (''value'' - ''compare value'').
'''Entity Name:''' logic_compare
{{clr}}


Compares an input value to another value. If the input value is less than the compare value, the OnLessThan output is fired with the input value. If the input value is equal to the compare value, the OnEqualTo output is fired with the input value. If the input value is greater than the compare value, the OnGreaterThan output is fired with the input value.
== Keyvalues ==
{{KV Targetname}}
{{KV|Initial value|intn=InitialValue|integer|Initial value for the input value.}}
{{KV|Compare value|intn=CompareValue|integer|The value to compare against.}}


==Entity Values==
== Inputs ==
===Keys===
{{I|SetValue|Set the value that will be compared against the compare value.|param=float}}
{{I|SetValueCompare|Set the value that will be compared against the compare value and performs the comparison.|param=float}}
{{note|Some Health based entities like {{ent|func_physbox}}. will base its percentage from<code>m_iMaxHealth</code> when using <code>OnHealthChanged</code> so any change in <code>health</code> will not be accounted for.}}
{{I|SetCompareValue|Set the compare value.|param=float}}
{{I|Compare|Force a compare of the input value with the compare value.}}


* '''Name''' ''targetname <target_source>''
== Outputs ==
** The name that other entities refer to this entity by.
{{O|OnLessThan|Fired when the input value is less than the compare value. Sends the input value as data.|param=float}}
* '''Initial value''' ''InitialValue <integer>''
{{O|OnEqualTo|Fired when the input value is equal to the compare value. Sends the input value as data.|param=float}}
** Initial value for the input value.
{{O|OnNotEqualTo|Fired when the input value is different from the compare value. Sends the input value as data.|param=float}}
* '''Compare value''' ''CompareValue <integer>''
{{O|OnGreaterThan|Fired when the input value is greater than the compare value. Sends the input value as data.|param=float}}
** The value to compare against.


 
[[Category:IO System]]
===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 <float>'''
** Set the value that will be compared against the compare value.
* '''SetValueCompare <float>'''
** Set the value that will be compared against the compare value and performs the comparison.
* '''SetCompareValue <float>'''
** Set the compare value.
* '''Compare'''
** Force a compare of the input value with the compare 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.
* '''OnLessThan <float>'''
** Fired when the input value is less than the compare value. Sends the input value as data.
* '''OnEqualTo <float>'''
** Fired when the input value is equal to the compare value. Sends the input value as data.
* '''OnNotEqualTo <float>'''
** Fired when the input value is different from the compare value. Sends the input value as data.
* '''OnGreaterThan <float>'''
** Fired when the input value is greater than the compare value. Sends the input value as data.
 
 
==Additional Info==
* Note the difference between the '''SetValueCompare''' and '''SetCompareValue''' inputs.
 
[[Category:Entities]]

Latest revision as of 04:52, 29 April 2025

Underlinked - Logo.png
This article needs more Wikipedia icon links to other articles to help Wikipedia icon integrate it into the encyclopedia. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024
English (en)中文 (zh)Translate (Translate)
Logic compare.png
C++ Class hierarchy
CLogicCompare
CLogicalEntity
CServerOnlyEntity
CBaseEntity
C++ logicentities.cpp

logic_compare is a logical entity available in all Source Source games. It examines the relationship between two numbers ("value" and "compare value"), and fires appropriate output(s).

The equation is (value - compare value).

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) <integer>
Initial value for the input value.
Compare value (CompareValue) <integer>
The value to compare against.

Inputs

SetValue <floatRedirectInput/float>
Set the value that will be compared against the compare value.
SetValueCompare <floatRedirectInput/float>
Set the value that will be compared against the compare value and performs the comparison.
Note.pngNote:Some Health based entities like func_physbox. will base its percentage fromm_iMaxHealth when using OnHealthChanged so any change in health will not be accounted for.
SetCompareValue <floatRedirectInput/float>
Set the compare value.
Compare
Force a compare of the input value with the compare value.

Outputs

OnLessThan <floatRedirectOutput/float>
Fired when the input value is less than the compare value. Sends the input value as data.
OnEqualTo <floatRedirectOutput/float>
Fired when the input value is equal to the compare value. Sends the input value as data.
OnNotEqualTo <floatRedirectOutput/float>
Fired when the input value is different from the compare value. Sends the input value as data.
OnGreaterThan <floatRedirectOutput/float>
Fired when the input value is greater than the compare value. Sends the input value as data.