Inputs and Outputs: Difference between revisions
TomEdwards (talk | contribs) |
TomEdwards (talk | contribs) (reded intro and #Outputs) |
||
Line 1: | Line 1: | ||
{{otherlang2|ru=Inputs_and_Outputs:ru}} | |||
'''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" an <code>OnTimer</code> output when it hits its time limit, which "triggers" the <code>ShowSprite</code> input on an [[env_sprite]]. When the timer hits its limit, the sprite appears. | |||
== Outputs == | |||
[[File:Output.png|thumb|Hammer's "Object Properties" dialog]] | |||
[[ | |||
'''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. | |||
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 {{bug|Valid classname and wildcard values will also appear red. Don't worry: the engine will recognise them!}} | |||
; Input name | |||
: An 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 [[ambient_generic|a sound]], the [[targetname]] of another entity, or perhaps [[color255|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 <code>OutValue</code>, generate parameters themselves. To use a generated parameter, just leave the field reading <code><none></code>. {{note|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. | |||
== Inputs == | == 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. | '''Inputs''' connect to outputs of any type. The Input tab shows all of the outputs that are connected from other entities to this entity. | ||
Line 33: | Line 37: | ||
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. | 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. | 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. | ||
== Setting up a simple trigger == | == Setting up a simple trigger == | ||
Line 79: | Line 75: | ||
* [[Targetname]] | * [[Targetname]] | ||
* [[User Inputs and Outputs]] | * [[User Inputs and Outputs]] | ||
[[Category:Level Design]] | [[Category:Level Design]] |
Revision as of 10:16, 22 July 2009
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" an OnTimer
output when it hits its time limit, which "triggers" the ShowSprite
input on an env_sprite. When the timer hits its limit, the sprite appears.
Outputs
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.
Outputs 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
Bug:Valid classname and wildcard values will also appear red. Don't worry: the engine will recognise them! [todo tested in ?]
- Input name
- An 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: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.
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 Check For Problems menu command will report them as an error.
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 (naming it "ambient_1"). Go into its properties and choose a sound file for it to play, and in its flags make sure it starts "Off". Select the "toolstrigger" texture and create a cube brush with this texture. Right-click on this brush and using the "Tie to Entity" command, make it into a trigger_once
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
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.
developer 0/1/2
- By setting this 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.
ent_messages_draw 0/1
- 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.
ent_fire <entity name> <input name> <input value>
- 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
ent_fire testentity open 3
. You can also fire any entity that is under your crosshair using "!picker" as the entity name. ent_pause
- 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
ent_step
command, described below. ent_step <number of steps>
- When used with the
ent_pause
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.ent_step 3
would execute three steps at once).