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

AddOutput: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
{{LanguageBar}}
{{LanguageBar}}
{{TabsBar|main=s2|base=AddOutput}}
{{TabsBar|main=s2|base=AddOutput}}
{{cleanup|The primary purpose of AddOutput is to add outputs to an entity (like the name implies). The fact that a lot of keyvalues can be changed with AddOutput is just a happy side effect of how outputs are stored in compiled maps (where they're just KVs with special formmating); no Valve maps use it that way. This page should be updated accordingly, and other pages which report a KV being unable to be edited with AddOutput as a bug should change it to a note instead, as it isn't a bug (since it isn't intended behavior.}}
{{cleanup|The primary purpose of AddOutput is to add outputs to an entity (like the name implies). The fact that a lot of keyvalues can be changed with AddOutput is just a happy side effect of how outputs are stored in compiled maps (where they're just KVs with special formmating); no Valve maps use it that way. This page has been updated accordingly, but other pages which report a KV being unable to be edited with AddOutput as a bug should change it to a note instead, as it isn't a bug (since it isn't intended behavior).}}
{{This is a|[[input]]|name=AddOutput}} Its primary purpose is registering additional actions for when entity's chosen [[output]] fires (usually referred to as simply adding an output).
{{This is a|[[input]]|name=AddOutput}} Its primary purpose is registering additional actions for when entity's chosen [[output]] fires (usually referred to as simply adding an output).



Revision as of 05:59, 4 April 2025

English (en)Русский (ru)中文 (zh)Translate (Translate)
Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality because:
The primary purpose of AddOutput is to add outputs to an entity (like the name implies). The fact that a lot of keyvalues can be changed with AddOutput is just a happy side effect of how outputs are stored in compiled maps (where they're just KVs with special formmating); no Valve maps use it that way. This page has been updated accordingly, but other pages which report a KV being unable to be edited with AddOutput as a bug should change it to a note instead, as it isn't a bug (since it isn't intended behavior).
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.

AddOutput is an input available in all Source Source games. Its primary purpose is registering additional actions for when entity's chosen output fires (usually referred to as simply adding an output).

Syntax:

<output> <target>:[input]:[parameter_override]:[delay]:[times to fire (-1 or 0 = infinity, 1 = once, 2 = twice ...)]
  • <> = mandatory parameter
  • [] = optional parameter
  • output - existing output on the given entity
  • target - targetname of the targeted entity (special targetnames like !caller, !activator, !self etc. are also supported)
  • input - input to be used on targeted entity (if left blank Use input us used)
  • parameter_override - parameter (if left blank and the given output holds a value then that will be automatically filled in)
  • delay - delay in seconds (left blank means 0)
  • times to fire - number of times this output can fire this action (left blank means -1)

Example

We have a math_counter named counter.

The following shows an output that could be setup on a trigger_once in Hammer:

My output named:                OnStartTouch
Target entities named:          counter
Via this input:                 AddOutput
With a parameter override of:   OutValue car:skin

The following are equivalent

  • OutValue car:skin
  • OutValue car:skin:::
  • OutValue car:skin::0:-1

The parameter_override is left blank which means it will be filled with value of math_counter's OutValue.

Warning.pngWarning:In Hammer don't use quotation characters (") in any of the fields (not even \" characters). It will cause fatal errors with opening and/or compiling your map and may need to be fixed by manually editing the VMF in a text editor. Instead, use detailed quotes (i.e. and ) or two apostrophes ( '' ).

Using AddOutput to change keyvalues

Because of the way it's implemented AddOutput also allows changing any entity's keyvalues. This includes targetname, rendercolor, solid and more. As this is not a purpose for which AddOutput was implemented not all keys will work as expected when changed this way. Syntax: <key> <value>

Due to how much AddOutput lets you manipulate entities properties it might be therefore a way to optimize maps which utilize env_entity_maker, point_teleport, game_text and more which count as edict.

Tip.pngTip:Abusing AddOutput too much makes your map harder to understand. Avoid abusing it unless necessary for your use case.

Examples of keyvalues whose change might not have desired effect

classname
classname is first key read from a map file and determines what C++ class to use to spawn an entity, therefore changing this later via AddOutput will not truly change an entity into a different one. But there are sometimes checks in code that determine some behavior purely on the value of classname for example see Preserved entities. ([Todo] some more example)
Warning.pngWarning:Doing this in games with save files is not advised as saving entity with wrong classname means it won't be recreated properly or at all
Warning.pngWarning:Changing the classname of a player causes problems and should be avoided at all costs.
Note.pngNote:Certain entities rely upon classname, so this is generally discouraged.
parentname
Won't have an effect when changed via AddOutput as parent/child hierarchy is setup when all entities are being spawned and not later.
SourceEntityName of ambient_generic
ambient_generic searches for the entity named SourceEntityName when it spawned so changing it later via AddOutput won't have an effect and this is usually a reason when any keyvalue change via AddOutput doesn't do what was expected


Limitations

  • It's not possible to add an output with this that uses AddContext input because AddContext also uses ':' in its syntax.
  • Since AddOutput uses a space in its syntax, outputs and keyvalues which have spaces cannot be modified. Fortunately, this is unlikely to ever be an issue, as no vanilla entities use spaces

Firing AddOutput via ent_fire

Because AddOutput uses space in its syntax it's required to enclose the ent_fire parameter in quotes.

To add output:

ent_fire <entity name> addoutput "<OutputName> <target>:<input>:<parameter_override>:<delay>:<refires>"

To change keyvalue:

ent_fire <entity name> addoutput "<key> <value>"

Examples

Format: <key> <value>
{
"classname" "trigger_once"
.
.
.
'OnStartTouch" "game_text,AddOutput,message There is a fire ahead. Go the other way!,0,1
'OnStartTouch" "game_text,Display,,0.02,1
} 

This changes the text of a game_text and then displays it. This is useful as to prevent having an unneccesary amount of game_text which counts as edict

Format: <output> <targetname>:<input>:<parameter>:<delay>:<refire>
{
"classname" "tf_logic_auto"
.
.
.
'OnMapSpawn" "team_round_timer_red,AddOutput,OnFinished game_round_win:RoundWin::0:-1,0,-1
}

This adds an output to an entity with the targetname "team_round_timer_red".


Trigger_Multiple
Name: Ghost


Outputs
My Output Named: OnEndTouch
Targets entities named: !activator
Via this input: Alpha
With a parameter override of: 255
After a delay in seconds: 0.10


My Output Named: OnStartTouch
Targets entities named: !activator
Via this input: AddOutput
With a parameter override of: rendermode 1
After a delay in seconds: 0.00


My Output Named: OnStartTouch
Targets entities named: !activator
Via this input: Alpha
With a parameter override of: 120
After a delay in seconds: 0.00


Results in translucent player when standing in the trigger_multiple (OnStartTouch) and visible again when not in the trigger_multiple (OnEndTouch).

See alsо