Logic case: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(As far as I know, OnUsed only exists in Mapbase)
(-added class hierarchy, cleanup)
Line 1: Line 1:
{{lang|Logic case}}
{{lang|Logic case}}
[[File:logic_case.png|left|link=]]
{{CD|CLogicCase|file1=logicentities.cpp}}
{{base point|logic_case}}
{{base point|logic_case}}


==Entity description==
It compares an input to up to 16 configured values, firing a corresponding output if there is a match (on <code>InValue</code>), or fires a random output (on <code>PickRandom</code>). Use [[logic_random_outputs]] for a weighted random output.
[[File:logic_case.png|left|link=]]It compares an input to up to 16 configured values, firing a corresponding output if there is a match (on <code>InValue</code>), or fires a random output (on <code>PickRandom</code>). Use [[logic_random_outputs]] for a weighted random output.


{{bug|This entity will not recognize [[float]]s with trailing zeroes (like <code>0.50</code> or <code>1.00</code>). Always remove any.}}
{{bug|This entity will not recognize [[float]]s with trailing zeroes (like <code>0.50</code> or <code>1.00</code>). Always remove any.}}


{{tip|Use with [[logic_timer]] for extremely random events.}}
{{tip|Use with [[logic_timer]] for extremely random events.}}
{{clr}}


== Keyvalues ==
== Keyvalues ==
{{KV|Case 01|to=Case 16|string|The values to test against.}}
{{KV|Case 01|to=Case 16|intn=Case01|intn2=Case16|string|The values to test against.}}
{{KV Targetname}}
{{KV Targetname}}


Line 18: Line 18:
{{IO|PickRandom|Fires a random OnCase output with at least one connection.}}
{{IO|PickRandom|Fires a random OnCase output with at least one connection.}}
{{IO|PickRandomShuffle|Fires a random OnCase output with at least one connection, with no repeats until all cases have been picked, at which point the shuffle starts over.}}
{{IO|PickRandomShuffle|Fires a random OnCase output with at least one connection, with no repeats until all cases have been picked, at which point the shuffle starts over.}}
{{I Targetname}}


== Outputs ==
== Outputs ==
Line 24: Line 23:
{{IO|OnDefault|Fired when the input value does not equal any of the Case values.}}
{{IO|OnDefault|Fired when the input value does not equal any of the Case values.}}
{{IO|OnUsed|Fired when an input value is received, regardless of whether it matches a case.|only={{mapbase}}}}
{{IO|OnUsed|Fired when an input value is received, regardless of whether it matches a case.|only={{mapbase}}}}
{{O Targetname}}


[[Category:IO System]]
[[Category:IO System]]

Revision as of 15:50, 6 November 2022

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

Template:Base point

It compares an input to up to 16 configured values, firing a corresponding output if there is a match (on InValue), or fires a random output (on PickRandom). Use logic_random_outputs for a weighted random output.

Icon-Bug.pngBug:This entity will not recognize floats with trailing zeroes (like 0.50 or 1.00). Always remove any.  [todo tested in ?]
Tip.pngTip:Use with logic_timer for extremely random events.

Keyvalues

Case 01 (Case01) to Case 16 (Case16) <string>
The values to test against.
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

Inputs

InValue <stringRedirectInput/string>
Compares the Input value to the case values, and fires the appropriate output, if any.
PickRandom
Fires a random OnCase output with at least one connection.
PickRandomShuffle
Fires a random OnCase output with at least one connection, with no repeats until all cases have been picked, at which point the shuffle starts over.

Outputs

OnCase01 to OnCase16
Fired when the input value equals the corresponding Case value.
OnDefault
Fired when the input value does not equal any of the Case values.
OnUsed  (only in Mapbase)
Fired when an input value is received, regardless of whether it matches a case.