Es/Inputs and Outputs

From Valve Developer Community
< Es
Revision as of 08:20, 13 May 2014 by Steelsoldier (talk | contribs)
Jump to navigation Jump to search

Template:Otherlang2

Cuando un niño se asusta de un sonido, en la informática se suele decir, que el niño ha cometido una entrada (reacción) al escuchar el sonido (acción del sonido, que es, asustar)

Entrada y salida, o mejor entendido "Hecho-consecuencia", reacción-acción (y no al revés) (conjuntamente "E/S" o en inglés "I/O") son términos para describir los medios por los cuales las entidades se comunican entre ellas en mapas. Las entidades tienen dos métodos para comunicarse: enviar una "salida" (señal que sale) a otra entidad, o a una "entrada" receptiva de otra entidad. Por ejemplo, una entidad puede mandar una salida cuando es eliminada a otra entrada de entidad que causa que cambie de color.

Imagina una entidad como un logic_timer. Podría estar configurada para "activar" su entrada OnTimer cuando llegue a un límite de tiempo, el cual activa (o llama) la salida ShowSprite de un "sprite" (env_sprite).


Entradas

Las entradas/acciones son comandos u acciones que causan que una entidad cambie lo que esté haciendo. Son activadas (o llamadas) por las salidas - no pueden ser manipuladas directamente.

En el Hammer Editor, puedes ver una lista de acciones que entidad (A) recibe, en la pestaña "Inputs", en las propiedades de un objeto. Haciendo clic en "Mark" te llevará a la entidad (B), que está activando la acción.

Salidas

"Object Properties" Ventana de las propiedades de una entidad, en Hammer

Las salidas/reacciones, son eventos, o sucesos, que se activan cuando hay un cambio en el estado de la entidad. Por así decirlo, un cronómetro (timer) podrá cometer una reacción al llegar al tiempo límite. Un botón (button) activará un evento al ser pulsado/apretado, o una pistola, desencadenará una reacción (disparar una bala) al apretar el gatillo.

Esto se entiende así:

1. Apretar el gatillo -> Acción
2. Una bala sale disparada -> Reacción
1. Cometer la acción, desencadenar algo = Acción
2. Consecuencia de la acción = Reacción
1. Un ejército verde invade el país azul = Acción
2. El ejército azul dispara contra el verde = Reacción

________________

Las reacciones son creadas en la pestaña "Outputs", en las propiedades de una entidad. Este menú te da una lista de reacciones, que están siendo emitidas, por la entidad que los emite, campos de texto para configurarlas y étcera. The output configuration fields are:

Output name (Nombre de la reacción)
¿Qué, qué cosa o quién causa a esta acción, activarse. Por ejemplo, un activador (trigger_multiple) puede activar un "al activar" (OnTrigger) una reacción cuando el jugador entra o interacciona en el activador.
Target entity (Objetivo)
El objetivo (targetname) o nombre de la clase (classname) de una entidad que recibirá la entrada/reacción. Se aceptan asteriscos (*) para buscar un objetivo con nombre incompleto/general.
  • En el Hammer Editor, un objetivo en negrita, son múltiples entidades con el mismo nombre.
  • Si se pone en rojo, significa que no se apunta a una entidad que se llame como el objetivo.
    Icon-Bug.pngError:Valid classname and wildcard values and special targetnames 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, 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.pngNota: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.

Cómo entenderlo mejor: Ejemplos

Para entenderlo mejor interpreta la tabla.

Lista de sucesos de una puerta
Entrada/Reacción Objetivo Salida/Acción Parámetro Tiempo de reacción Ocurrir sólo una vez
Entity-output-icon.png Al abrir la puerta Luz de la habitación Encender la luz <ninguno> 1.00 segundo
Entity-output-icon.png Al abrir la puerta Personas escondidas Salir del escondite <ninguno> 1.50 segundos
Entity-output-icon.png Al salir del escondite Personas escondidas Reconocerlas como <Invitados de cumpleaños> 1.55
Entity-output-icon.png Al ver al objetivo Invitados de cumpleaños Felicitar <Persona que ha abierto la puerta> 0.00

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 (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" 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

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.pngError: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 that enables cheats (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>
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.pngConsejo: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 perform a specified number of I/O steps before pausing again (default is 1).

See also