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

Inputs and Outputs

From Valve Developer Community
Jump to: navigation, search
Under construction.png
This page is actively undergoing a major edit.
As a courtesy, please do not edit this while this message is displayed.
If this page has not been edited for at least several hours to a few days, please remove this template. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page.

The person who added this notice will be listed in its edit history should you wish to contact them.

Info content.png
This page needs to be translated.
This page either contains information that is only partially or incorrectly translated, or there isn't a translation yet.
If this page cannot be translated for some reason, or is left untranslated for an extended period of time after this notice is posted, the page should be requested to be deleted.
Also, please make sure the article tries to comply with the alternate languages guide.
English (en)Deutsch (de)Español (es)Polski (pl)Português do Brasil (pt-br)Русский (ru)中文 (zh)Translate (Translate)

Inputs and Outputs (collectively "I/O") are the means by which entities(en) communicate between each other in maps(en). Entities have two methods for communication: sending an "output" to another entity, or receiving an "input" from another entity. For example, one entity may send an output when it is killed to another entity's input which causes it to change color. That same output could also be used to trigger another entity's spawning input. The outputs are matched to the inputs via a "connection", which controls what extra data is relayed to the receiver, how much of a delay there is before the output is received, and whether the output should be allowed to be sent again later. Outputs can be linked to any input and vice versa. This allows complex and powerful interactions between entities.

Consider a Logic timer(en) entity. It might be configured to "fire" its OnTimer output when it hits its time limit, which "triggers" (or "calls") the ShowSprite input of an Env sprite(en). When the timer hits its limit, the sprite appears. By using the connection properties, you could also cause the output to be triggered after a two second delay, or to trigger once but never again.

Inputs

Inputs are commands that cause an entity to change what it is doing. They are "triggered" (or "called") by outputs - they cannot be manipulated directly.

You can view a list of input events that an entity is receiving in the Inputs tab of the object properties dialog(en). Clicking the "mark" button will take you to the entity that the input is being received from.

  1. Use(en)

Outputs

Hammer's "Object Properties" dialog

Outputs are events that fire when an entity's state changes. For example, a timer(en) will have an output for reaching its end, a button(en) an output for being pressed, and a door(en) an output for coming to a close.

Output events are created in the Outputs tab of the object properties dialog(en). This interface provides a list of the outputs already emitting from the entity, configuration fields for the one(s) currently selected, and buttons for creating new and deleting old. Finally, the button in the bottom left labelled "mark" will take you to the target entity of the current output.

The output configuration fields are:

Output name
What event causes the output to fire. For example, a Trigger multiple(en) entity can fire an OnTrigger output when a player steps into it.
Target entity
The Targetname(en) or Classname(en) of the entity that will receive input. Accepts the * character as a search wildcard.
  • A bold name means that the targetname points to multiple entities
  • A red name means that the targetname doesn't point to anything
    Icon-Bug.pngErro:Valid classname and wildcard values and special targetnames(en) will also appear red. Don't worry: the engine will recognise them!  [todo tested in?]
Input name
The input on the target entity that will be triggered. This too will be context sensitive. For example, if sending an output to a Door entity, some of the available inputs will be "Close" or "Open".
Parameters
You can pass data to the target entity with parameters. A parameter might be anything: how loud to play a sound(en), the Targetname(en) of another entity, or perhaps a color(en). It all depends on what the input accepts. If it doesn't accept anything, this field will be greyed out.
Some outputs, like Math counter(en)'s OutValue, generate parameters themselves. To use a generated parameter, just leave the field reading <none>.
Note.pngNota:If the output value is a Targetname(en), remember that it may not be unique!
Time delay
The number of seconds to wait after the output event occurs before firing.
Fire once only
The output will be deleted after it fires if this is checked.

Setting up a simple trigger

This is an example of how to make a simple trigger using inputs and outputs, so a sound is played when the player enters a specific area.

Open up a map and add an Ambient generic(en) (in the Name field, type in "ambient_1"). Go into its Object Properties and choose a sound file for it to play, and on the Flags tab make it set to "Start Silent". Select the "tools/toolstrigger" texture and create a cube brush with this texture. Right-click on this brush and using the "Tie to Entity(en)" command, make it into a Trigger once(en) entity. Go to the Outputs tab and click the Add... button.

Set "My output named" to "OnStartTouch". This causes the output (and thus the trigger) to occur when the player starts touching this brush in the game.

Set "Targets entities named" to "ambient_1" using the pull-down arrow. This makes the trigger output target the ambient_generic you placed earlier.

Set "Via this input" to "PlaySound". This chooses the PlaySound action from the target ambient_generic's list of actions, which of course causes its sound to start playing.

Click the Apply button to save your changes to the trigger, and close it. Now we have the trigger set up so that as soon as the player touches it, it sends a command to the ambient_generic which makes it start playing its sound.

If you open up the properties for the ambient_generic, you can see how the Output from the trigger has automatically been converted to an Input for the ambient_generic.

If you want to compile and test your new trigger, make sure you have all the basics (player start, lighting, etc) and have assigned a sound effect to the ambient_generic.

Debugging

Source provides various debugging tools for when an I/O chain is not working as expected.

Foremost among them is the object properties dialog itself. Invalid inputs outputs are highlighted red in the entity's input or output list; the I/O icons at the bottom of the dialoge also change accordingly. Invalid outputs also show up in Check For Problems(en) (Alt+P). It's a good idea check for problems before every compile.

Icon-Bug.pngErro:Valid classname and wildcard values(en) will be flagged as errors. Don't worry: the engine will recognise them!  [todo tested in?]

Away from Hammer, there are a number of console(en) commands and variables that will help you spot errors while your map is running:

developer <0-2>
Developer mode(en) reports all entity I/O to the console, and unless you're playing on a Dedicated server(en) that enables cheats(en) (which is needed for all of the commands below). If you are in developer 2, you will also get the last eight lines of the console displayed at the top of your screen.
ent_messages_draw <Bool(en)>
This displays the same information as developer mode, except that instead of appearing in the console it's drawn in the 3D world at the location of the entities in question.
ent_fire <Targetname(en) or Classname(en)> <input> <parameter>
This extremely useful command allows you to manually fire inputs on any entity at any time. If you want to unlock a door ahead of time, you would type ent_fire my_door unlock, followed if you're feeling lazy by ent_fire my_door open.
Like the "output target" field in Hammer, ent_fire supports classnames and wildcards. If you want to ent_fire npc_* ignite, you can!
Tip.pngDica:ent_fire is where the special !picker(en) targetname comes in. Use it to target whatever is under your crosshair.
ent_pause
This command pauses all entities in the map except the player; submit it again to unpause. It is designed for use with ent_step.
ent_step <number of steps>
When used with ent_pause, this command makes entities perform a specified number of I/O steps before pausing again (default is 1).

See also