Generic Keyvalues, Inputs and Outputs/Inputs: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(This made every entity page subheading display russian flags.)
(→‎Inputs: Put primary AddOutput purpose first and made formatting consistent)
 
(66 intermediate revisions by 19 users not shown)
Line 1: Line 1:
<noinclude>{{otherlang2
== Inputs ==
|noborder=true
{{I|[[AddOutput]]|Assigns a new output/keyvalue on this entity. For keyvalues, some rely on extra necessary code to be ran and won't work if it's simply just changed through this input.<br />Format: {{code|<output name> <target>:[input name]:[parameter]:[delay]:[max times to fire, -1 means infinite]}}<br />Format: {{code|<key> <value>}}|param=string}}
|ru=Template:I_BaseEntity:ru
{{I|[[Kill]]|Removes this entity and any entities parented to it from the world.}}
}}__NOTOC__
{{I|FireUser1|to=FireUser4&nbsp;|param=string|Fires the respective<code>OnUser</code>outputs; see [[User Inputs and Outputs]].
:{{warning|Can take string parameter and doesn't do anything with it. This can cause an issue if this input is fired from outputs that can send a value. Make sure to specify dummy string in such cases other-wise the output will use its value as parameter causing the input to fail with "bad input/output link" error in console.}}}}
{{I|SetDamageFilter|param=targetname|Sets a [[filter]] for this entity for when it receives damage.}}


This template is our holder for all [[inputs]] assigned through {{ent|CBaseEntity}}. The template has a very specific syntax that you must follow to apply properly, because new games have added new features throughout the years. See [[Help:Templates]] for more info on named parameters.
=== Parenting ===
<pre>{{I BaseEntity}}</pre>
{{I|SetParent|param=targetname|special targets = supports !activator but not !caller|Move with this entity. See [[Entity Hierarchy (parenting)]].}}
'''No parameters:''' display inputs for ALL games.
{{I|SetParentAttachment|Change this entity to attach to a specific [[attachment]] point on its parent. The entity will teleport so that the position of its root [[bone]] matches that of the attachment.  Entities must be parented before being sent this input.|param=string}}
<pre>{{I BaseEntity|base=1}}</pre>
{{I|SetParentAttachmentMaintainOffset|As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.|param=string}}
'''Base:''' display inputs that have only existed since whatever game added the class (most have existed since HL2, the first Source game).
{{I|ClearParent|Removes this entity from the movement hierarchy, leaving it free to move independently.}}
<pre>{{I BaseEntity|l4d2=1}}</pre>
{{I|KillHierarchy|Functions the same as <code>Kill</code>, although this entity and any entities parented to it are killed on the same frame, being marginally faster than<code>Kill</code>input.}}
'''Game as a parameter:''' display the inputs that <code>base</code> displays, AND inputs that were added to the class, by the specified game. You can specify as many games as needed. You must specify ALL the games you want to include (e.g. <code>l4d2</code> will not automatically include <code>l4d</code> inputs as well).


All parameters for this template:
=== VScript <span id="VScript inputs" /> ===
*<code>base</code>
{{I|RunScriptFile|param=script|Execute a [[VScript]] file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.|since={{l4d2}}|also={{tf2branch}}}}
*<code>l4d2</code>
{{I|RunScriptCode|param=string|Execute a string of VScript source code in the scope of the entity receiving the input. Variables <code>activator</code>, <code>caller</code>, <code>self</code> are available when the script is run (same applies to <tt>RunScriptFile</tt>).
*<code>portal2</code>
:{{Hammer quote warning}}
*<code>prel4d</code> - (DEPRECATED 9/28/18: This parameter existed to hide DispatchEffect for games (ones before l4d) that did not have it. There's many cases of similar inputs and keyvalues that aren't in absolutely everything, and making similar parameters for all of those simply isn't worth the trouble, especially considering having to comb through every existing use of those templates. Parameter is totally removed from code and affects nothing.)
:{{tip|1=In {{tf2branch}} backticks {{code2|`}} are converted to {{code2|"}} when the input is processed. If a string is needed in other games then <code>foreach</code> can be used like <code>foreach(k,v in {the_string_I_need=0}) printl(k)</code>, but that looks confusing and only strings that are also valid identifiers can be created this way so it's preferable to use <tt>RunScriptFile</tt> or [[Entity Scripts]] instead. Mind that using quotes itself within IO events is not an issue, so using <code>EntFire</code> or adding outputs via script can be done by escaping the quotes <code>\"</code>. Hammer does not provide a way to escape them. Example: <code>EntFire("target", "RunScriptCode", "printl(\"I am: \" + self + \" !\")")</code>.}}
{{note|If you want to edit something on this template, please make sure you edit it in both places. ''Per-game'' inputs are duplicated, for complex technical reasons.}}
:{{bug|hidetested=1|Trying to use <code>activator</code> or <code>caller</code> by running this input on an entity that doesn't yet have a script scope will cause error as those variables are only populated when script scope exists. Calling the input second time will have them because the first call did create the script scope. This is fixed in {{tf2branch|2}}.}}
For full documentation on this family of templates, see [[FGD Template Prototype]]. Still confused on something? '''Ask for help''' before editing this template.
|since={{l4d2}}|also={{tf2branch}}}}
{{note|Some <code>CBaseEntity</code> inputs are not covered here. See the talk page.}}
{{I|CallScriptFunction|Calls a VScript function defined in the scope of the receiving entity.|param=string|since={{l4d2}}|also={{tf2branch}}|nofgd=1}}
[[Category:Input Templates|Global]]
{{I|TerminateScriptScope|Destroys the script scope of the receiving entity.|only={{tf2branch}}|nofgd=1}}
----
 
</noinclude><!--
=== Context ===
-->{{minititle|Base}}
{{I|AddContext|Adds to the entity's list of [[Response System|response contexts]]. See [[Context|Context]].|param=string}}
{{IO|Kill|Removes this entity and any entities parented to it from the world.}}
{{I|ClearContext|Removes all contexts from this entity's list.
{{IO|KillHierarchy|Functions the same as <code>Kill</code>, although this entity and any entities parented to it are killed on the same frame.}}
:{{warning|Should not be used outside of debugging purposes if vscript modding is available as one never knows what they might be deleting especially on player entities. There are often vscript mods that store information as contexts for various purposes. }} }}
{{IO|SetParent|Move with this entity. See [[Entity Hierarchy (parenting)]].|param=string}}
{{I|RemoveContext|Remove a context from this entity's list. The name should match the key of an existing context.|param=string}}
{{IO|SetParentAttachment|Change this entity to attach to a specific [[attachment]] point on its parent. The entity will teleport so that the position of its root [[bone]] matches that of the attachment.  Entities must be parented before being sent this input.|param=string}}
 
{{IO|SetParentAttachmentMaintainOffset|As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.|param=string}}
=== Rendering ===
{{IO|ClearParent|Removes this entity from the the movement hierarchy, leaving it free to move independently.}}
{{I RenderFields}}
{{IO|[[AddOutput]]|Evaluates a keyvalue/output on this entity. <br/>Format: <code><key> <value></code><br/>Format: <code><output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite></code>|param=string}}
{{I Shadow}}
{{IO|FireUser1|to=FireUser4|Fire the <code>OnUser</code> outputs; see [[User Inputs and Outputs]].}}
 
{{IO|Use|Same as a player invoking [[+use]]; may not do anything. Can also be invoked by creating an output that does not specify an input.<br /> This input is not included in Valve's [[FGD]]s.|nofgd=1}}
=== Miscellaneous ===
{{IO|DispatchEffect|Dispatches a special effect from the entity's origin. Removed and replaced entirely by the [[particle]] system since {{l4d}}.|param=string|nofgd=1}}
{{Expand|
{{IO|DispatchResponse|Dispatches a response to the entity. See [[Response]] and [[Concept]].|param=string|nofgd=1}}
{{I|Use|Same as a player invoking [[+use]]; no effect in most cases.|nofgd=1}}
{{IO|AddContext|Adds to the entity's list of [[Response System|response contexts]]. Format is <code><key>:<value></code>.|param=string}}
{{I|SetTeam|Changes this entity's team.|nofgd=1|param=integer}}
{{IO|RemoveContext|Remove a context from this entity's list. The name should match the key of an existing context.|param=string}}
{{I|TeamNum|This input changes value for <code>TeamNum</code> property.|nofgd=1|param=integer}}
{{IO|ClearContext|Removes all contexts from this entity's list.|param=string}}<!--
{{I|DispatchResponse|Dispatches a response to the entity. See [[Response]] and [[Concept]].|param=string|nofgd=1}}
-->{{#if:{{{l4d2|}}}|<!--
{{I|DispatchEffect|Dispatches a special effect from the entity's origin; See also [[List of Client Effects]]. Replaced by the [[particle]] system since {{l4d}}.|param=string|removed={{l4d}}|nofgd=1}}
-->{{IO|RunScriptFile|Execute a [[VScript]] file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.|param=script|since=L4D2}}
{{I|SetLocalOrigin|Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.|param=coordinates|since={{portal 2}}|nofgd=1}}
{{IO|RunScriptCode|Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console. {{bug|In {{l4d2}}, the code is executed in the script scope of the entity that fires the output, ''not'' the one receiving the input.}} {{warning|Never try to pass string parameters to a script function with this input. It will corrupt the [[VMF]] structure because of the nested quotation marks, which then must be removed manually with a text editor.}}|param=string|since=L4D2}}
{{I|SetLocalAngles|Set this entity's angles.|param=angles|since={{portal 2}}|nofgd=1}}
{{IO|CallScriptFunction|Execute a VScript function in the scope of the receiving entity.|param=string|since=L4D2|nofgd=1}}<!--
}}
-->| }}{{#if:{{{portal2|}}}|<!--
-->{{IO|SetLocalOrigin|param=coordinates|since=p2|nofgd=1|Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.}}
{{IO|SetLocalAngles|param=angles|since=p2|nofgd=1|Set this entity's angles.}}<!--
-->| }}{{#if:{{{l4d2|}}}||{{#if:{{{portal2|}}}||{{#if:{{{base|}}}||<!--
-->{{IO|RunScriptFile|Execute a [[VScript]] file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.|param=script|since=L4D2}}
{{IO|RunScriptCode|Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console. {{bug| In {{l4d2}}, the code is executed in the script scope of the entity that fires the output, ''not'' the one receiving the input.}} {{warning|Never try to pass string parameters to a script function with this input. It will corrupt the [[VMF]] structure because of the nested quotation marks, which then must be removed manually with a text editor.}}|param=string|since=L4D2}}
{{IO|CallScriptFunction|Execute a VScript function in the scope of the receiving entity.|param=string|since=L4D2|nofgd=1}}
{{IO|SetLocalOrigin|param=coordinates|since=p2|nofgd=1|Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.}}
{{IO|SetLocalAngles|param=angles|since=p2|nofgd=1|Set this entity's angles.}}<!--
-->}}}}}}

Latest revision as of 21:25, 26 July 2025

Inputs

AddOutput <stringRedirectInput/string>
Assigns a new output/keyvalue on this entity. For keyvalues, some rely on extra necessary code to be ran and won't work if it's simply just changed through this input.
Format: <output name> <target>:[input name]:[parameter]:[delay]:[max times to fire, -1 means infinite]
Format: <key> <value>
Kill
Removes this entity and any entities parented to it from the world.
FireUser1 to FireUser4  <stringRedirectInput/string>
Fires the respectiveOnUseroutputs; see User Inputs and Outputs.
Warning.pngWarning:Can take string parameter and doesn't do anything with it. This can cause an issue if this input is fired from outputs that can send a value. Make sure to specify dummy string in such cases other-wise the output will use its value as parameter causing the input to fail with "bad input/output link" error in console.
SetDamageFilter <targetnameRedirectInput/string>
Sets a filter for this entity for when it receives damage.

Parenting

SetParent <targetnameRedirectInput/string>
supports !activator but not !caller
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment <stringRedirectInput/string>
Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
SetParentAttachmentMaintainOffset <stringRedirectInput/string>
As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
ClearParent
Removes this entity from the movement hierarchy, leaving it free to move independently.
KillHierarchy
Functions the same as Kill, although this entity and any entities parented to it are killed on the same frame, being marginally faster thanKillinput.

VScript

RunScriptFile <scriptRedirectInput/string> (in all games since Left 4 Dead 2) (also in Team Fortress 2 branch)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode <stringRedirectInput/string> (in all games since Left 4 Dead 2) (also in Team Fortress 2 branch)
Execute a string of VScript source code in the scope of the entity receiving the input. Variables activator, caller, self are available when the script is run (same applies to RunScriptFile).
Warning.pngWarning:Using the quote symbol " in any text field of a Hammer Object Properties Dialog will lead to VMF corruption, fixable only by editing the VMF directly with a text editor and removing the added quote symbol.
Tip.pngTip:In Team Fortress 2 branch backticks ` are converted to " when the input is processed. If a string is needed in other games then foreach can be used like foreach(k,v in {the_string_I_need=0}) printl(k), but that looks confusing and only strings that are also valid identifiers can be created this way so it's preferable to use RunScriptFile or Entity Scripts instead. Mind that using quotes itself within IO events is not an issue, so using EntFire or adding outputs via script can be done by escaping the quotes \". Hammer does not provide a way to escape them. Example: EntFire("target", "RunScriptCode", "printl(\"I am: \" + self + \" !\")").
Icon-Bug.pngBug:Trying to use activator or caller by running this input on an entity that doesn't yet have a script scope will cause error as those variables are only populated when script scope exists. Calling the input second time will have them because the first call did create the script scope. This is fixed in Team Fortress 2 branch Team Fortress 2 branch.
CallScriptFunction <stringRedirectInput/string> (in all games since Left 4 Dead 2) (also in Team Fortress 2 branch) !FGD
Calls a VScript function defined in the scope of the receiving entity.
TerminateScriptScope  (only in Team Fortress 2 branch) !FGD
Destroys the script scope of the receiving entity.

Context

AddContext <stringRedirectInput/string>
Adds to the entity's list of response contexts. See Context.
ClearContext
Removes all contexts from this entity's list.
Warning.pngWarning:Should not be used outside of debugging purposes if vscript modding is available as one never knows what they might be deleting especially on player entities. There are often vscript mods that store information as contexts for various purposes.
RemoveContext <stringRedirectInput/string>
Remove a context from this entity's list. The name should match the key of an existing context.

Rendering

RenderFields:

Alpha <integer 0–255>
Sets the entity's transparency to a number from 0 (invisible) to 255 (fully visible). Requires the entity to have its rendermode set to a number other than 0.
Color <color255RedirectInput/color32>
Sets an RGB color for the entity.

Shadow:

DisableShadow
Turn dynamic shadows off for this entity. Identical to applying  EF_NOSHADOW.
EnableShadow
Turn dynamic shadows on for this entity.
DisableReceivingFlashlight  (in all games since Portal 2)
This object will not receive light or shadows from projected textures.
EnableReceivingFlashlight  (in all games since Portal 2)
This object may receive light or shadows from projected textures.

Miscellaneous

Use  !FGD
Same as a player invoking +use; no effect in most cases.
SetTeam <integerRedirectInput/integer> !FGD
Changes this entity's team.
TeamNum <integerRedirectInput/integer> !FGD
This input changes value for TeamNum property.
DispatchResponse <stringRedirectInput/string> !FGD
Dispatches a response to the entity. See Response and Concept.
DispatchEffect <stringRedirectInput/string> (removed since Left 4 Dead) !FGD
Dispatches a special effect from the entity's origin; See also List of Client Effects. Replaced by the particle system since Left 4 Dead.
SetLocalOrigin <coordinates> (in all games since Portal 2) !FGD
Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
SetLocalAngles <anglesRedirectInput/Vector> (in all games since Portal 2) !FGD
Set this entity's angles.