Inputs and Outputs: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(redid #Debugging)
Line 1: Line 1:
{{otherlang2|ru=Inputs_and_Outputs:ru}}
{{otherlang2
| ru = Inputs and Outputs:ru
}}
 
{{toc-right}}


'''Inputs''' and '''Outputs''' (collectively "I/O") are the means by which [[Entity|entities]] communicate between each other in [[:Category:Level Design|maps]]. An output targets an input of another entity.
'''Inputs''' and '''Outputs''' (collectively "I/O") are the means by which [[Entity|entities]] communicate between each other in [[:Category:Level Design|maps]]. An output targets an input of another entity.


Consider a [[logic_timer]] entity. It might be configured to "fire" its <code>OnTimer</code> output when it hits its time limit, which "triggers" the <code>ShowSprite</code> input of an [[env_sprite]]. When the timer hits its limit, the sprite appears.
Consider a [[logic_timer]] entity. It might be configured to "fire" its <code>OnTimer</code> output when it hits its time limit, which "triggers" or "calls" the <code>ShowSprite</code> input of an [[env_sprite]]. When the timer hits its limit, the sprite appears.
 
== 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 [[Hammer Object Properties Dialog|object properties dialog]]. Clicking the "mark" button will take you to the entity that the input comes from.


== Outputs ==
== Outputs ==
Line 11: Line 21:
'''Outputs''' are events that fire when an entity's state changes. A [[logic_timer|timer]] will have an output for reaching its end, a [[func_button|button]] an output for being pressed, and a [[prop_door_rotating|door]] an output for coming to a close.
'''Outputs''' are events that fire when an entity's state changes. A [[logic_timer|timer]] will have an output for reaching its end, a [[func_button|button]] an output for being pressed, and a [[prop_door_rotating|door]] an output for coming to a close.


Outputs are created in the Outputs tab of the [[Hammer Object Properties Dialog|object properties dialog]]. 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.
Output events are created in the Outputs tab of the [[Hammer Object Properties Dialog|object properties dialog]]. 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:
The output configuration fields are:
Line 30: Line 40:
; Fire once only
; Fire once only
: The output will be deleted after it fires if this is checked.
: The output will be deleted after it fires if this is checked.
== Inputs ==
'''Inputs''' connect to outputs of any type. The Input tab shows all of the outputs that are connected from other entities to this entity.
Because any output can connect to any input, there is a multitude of combinations that can be used to create complex entity interactions. Timers can orchestrate a countdown sequence using blinking sprites, sounds and special effects all without any need for special entities. By clicking the "Mark" button or double-clicking on an entry in the list, the user is able to go to the entity sending the output to the input in question.
If a connection is displayed in red, it is invalid. This means that either the output does not exist in the source entity, or the input is not present in the destination entity. Invalid connections are benign but should be fixed before map compilation because the [[Hammer_Check_For_Problems_Dialog|Check For Problems]] menu command will report them as an error.


== I/O entities ==
== I/O entities ==
Line 49: Line 51:
== Debugging ==
== Debugging ==


Because the nature of how entities communicate has become more complex and powerful, so too has the debugging capabilities of the engine to help you track down problems. If a chain of I/O logic is not working as expected, the tools below will aid greatly in solving the error.
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 [[Hammer Check For Problems Dialog|Check For Problems]] ({{key|Alt+P}}). It's a good idea check for problems before every compile.
 
{{bug|Valid classname and wildcard values will be flagged as errors. Don't worry: the engine will recognise them!}}
 
Away from Hammer, there are a number of [[Developer console|console]] commands and variables that will help you spot errors while your map is running:


;<code>developer 0/1/2</code>
; <code>developer <0-2></code>
:By setting this [[ConVar|console variable]] (cvar) to a value of "2", you'll receive a detailed log of how the entities are interacting via the entity I/O system. This is useful for seeing the exact chain of events taking place in complex interactions.
: Developer mode reports all entity I/O to the console, and unless you're playing on a [[dedicated server]] also enables [[sv_cheats|cheats]] (which is required for all of the commands below). If you are in <code>developer 2</code>, you will also get the last eight lines of the console displayed at the top of your screen.
;<code>ent_messages_draw 0/1</code>
; <code>ent_messages_draw <[[bool]]></code>
:Setting this cvar to a value of "1" will display visual information about how entities are communicating with one another. This is very similar to using the developer cvar, but can sometimes be more immediately intuitive to the viewer.
: 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.
;<code>ent_fire <entity name> <input name> <input value></code>
; <code>ent_fire <[[targetname]] or [[classname]]> <input> <parameter></code>
:This console command allows you to manually fire inputs on an entity from the console. This can be very useful for testing settings for entities in real-time. To fire the "Open" input for an entity named "testentity" with an input parameter of "3", you would type <code>ent_fire testentity open 3</code> . You can also fire any entity that is under your crosshair using "!picker" as the entity name.
: 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 <code>ent_fire my_door unlock</code>, followed if you're feeling lazy by <code>ent_fire my_door open</code>.
;<code>ent_pause</code>
: Like the "output target" field in Hammer, <code>ent_fire</code> supports classnames and wildcards. If you want to <code>ent_fire npc_* ignite</code>, you can! {{tip|<code>ent_fire</code> is where the special <code>[[!picker]]</code> targetname comes in. Use it to target whatever is under your crosshair.}}
:This [[command]] pauses entities in the map. If entered again, the entities will resume their normal behavior. This is most useful when use with the <code>ent_step</code> command, described below.
; <code>ent_pause</code>
;<code>ent_step <number of steps></code>
: This command pauses all entities in the map except the player; submit it again to unpause. It is designed for use with <code>ent_step</code>.
:When used with the <code>ent_pause</code> [[console command]], this command allows the user to slowly step through an entity's chain of execution for input and output. Any number of steps can be iterated through at one time, as specified by a value entered after the command (e.g. <code>ent_step 3</code> would execute three steps at once).
; <code>ent_step <number of steps></code>
: When used with <code>ent_pause</code>, this command makes entities to perform a specified number of I/O steps before pausing again (default is 1).


== See also ==
== See also ==

Revision as of 12:25, 23 July 2009

Template:Otherlang2

Inputs and Outputs (collectively "I/O") are the means by which entities communicate between each other in maps. An output targets an input of another entity.

Consider a logic_timer 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. When the timer hits its limit, the sprite appears.

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. Clicking the "mark" button will take you to the entity that the input comes from.

Outputs

Hammer's "Object Properties" dialog

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

Output events are created in the Outputs tab of the object properties dialog. 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.
Target entity
The targetname or classname 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.pngBug:Valid classname and wildcard values 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 fired.
Parameters
You can pass data to the target entity with parameters. A parameter might be anything: how loud to play a sound, the targetname of another entity, or perhaps a color. 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's OutValue, generate parameters themselves. To use a generated parameter, just leave the field reading <none>.
Note.pngNote:If the output value is a targetname, 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.

I/O entities

[Todo]

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 (Alt+P). It's a good idea check for problems before every compile.

Icon-Bug.pngBug:Valid classname and wildcard values 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 commands and variables that will help you spot errors while your map is running:

developer <0-2>
Developer mode reports all entity I/O to the console, and unless you're playing on a dedicated server also enables cheats (which is required 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>
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 or classname> <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.pngTip:ent_fire is where the special !picker 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 to perform a specified number of I/O steps before pausing again (default is 1).

See also