Talk:AddOutput

From Valve Developer Community
Jump to navigation Jump to search

Proper Syntax for AddOutput

While using Hammer, with the Object Properties window open, you'll press the Outputs tab, then click "Add..." At this point, you'll choose an Output listed in the "My output named" list and begin entering your parameters/options/arguments.

For example, on a team_control_point_round, you might add an output that reads as follows:

My output named: OnStart
Targets entities named: Timer_Game
Via this input: AddOutput
With a parameter override of: OnSetupFinished door_one:Open::0:-1
After a delay in seconds of: 0.00
Fire once only (checkbox): Unchecked


Breakdown of the parameter override line...

"OnSetupFinished" is an Output for the team_round_timer entity.
"door_one" is the name of the entity I want affected by this output.
"Open" is the parameter (command) I send to the specified entitiy (door_one) in this case.
The "::" tells the engine that I'm not sending any other parameters with that "Open" command.
"0" is the delay (meaning, I want it done immediately).
"-1" means I want it to fire an infinite number of times.

Basically, I've created an output that tells another entity to create an output that tells a door to open when the setup timer is finished.
Note: Do NOT enclose your parameter override string in quotation marks ("OnSetupFinished door_one:Open::0:-1"). The compiler will give you an error and crash.

Page information incorrect and incomplete

Note.pngNote: I only tested this for the Portal2 SDK.


1) The information about <max times to fire> is wrong. Using 0 is the same as using -1. If you want the string to fire only once, use 1.


2) You can also use the comma as a delimeter.


3) <max times to fire> and <delay> can be omitted from the string in any combination.


The following strings will produce the same result; sound when triggered with zero delay:


OnTrigger amb_sound_bell,PlaySound,,0,-1

OnTrigger amb_sound_bell,PlaySound,,0,

OnTrigger amb_sound_bell,PlaySound,,,-1

OnTrigger amb_sound_bell,PlaySound,,,


4) By far the most interesting part is when using the AddOutput parameter you can actually control the number of <max times to fire>


OnTrigger amb_sound_bell,PlaySound,,,4 - means the sound can be triggered 4 times and then no more.


Please confirm for Portal2 SDK and/or other SDKs.


(--Species3259 09:24, 17 September 2017 (UTC)--)

"use use"

Was use use a mistake in the sentence Instead, use use detailed quotes (i.e. “ and ”).? --Mandrew (talk) 02:42, 24 April 2022 (PDT)

Intended use case

So I noticed this article is written as if AddOutput's main purpose is changing entity's keyvalues and adding an output is a bonus. But it's actually the other way around. Its main purpose is adding outputs and the fact it can change keyvalues is just a bonus quirk of it because of how it's implemented. Checked all hl2 series, portal 1 and l4d series maps and none use it to change keyvalues but only to add outputs. Also seen a few bug notices on some keyvalues saying "this keyvalue can't be changed via addoutput" which really shouldn't be considered bugs. --Nescius (talk) 17:16, 3 April 2025 (PDT)

note addition

"This traditionally occurs in the entity's KeyValue() function, which is common with GoldSrc-style code. As such, it is particularly common with legacy entities." I am not sure I fully understand that. Every keyvalue has to go through KeyValue method to be processed. And I don't think keyvalue's value being processed only during spawning/activating the entity is in particular a goldsrc thing --Nescius (talk) 08:31, 5 May 2025 (PDT)

I was misunderstanding how it worked. Now I see it doesn't seem to matter if DEFINE_KEYFIELD (the thing that streamlines KV handling compared to GoldSrc, iiuc) is used, regardless, as SourceEntityName actually does use DEFINE_KEYFIELD (but a bunch of other ambgen KVs don't).
SirYodaJedi (talk) 09:16, 5 May 2025 (PDT)
Yea the keys defined using DEFINE_KEYFIELD are handled in the CBaseEntity::KeyValue method--Nescius (talk) 10:11, 5 May 2025 (PDT)