Difference between revisions of "Scripting/es"
LuigiThirty (talk | contribs) (→Comandos Básicos) |
LuigiThirty (talk | contribs) (→Incrementvar) |
||
Line 66: | Line 66: | ||
==Incrementvar== | ==Incrementvar== | ||
− | + | Eso comando es para ciclar a través de un rango de valores cada vez que se ejecutar y se aplicar los valores a el otro comando. Hay el formo: | |
− | :''' | + | :'''comando "<argumento1>" "incrementvar <argument2> X Y Z"''' |
− | :*X | + | :*X y Y represente el rango de valores se quiere ejecutar con <argumento2>. |
− | :*Z | + | :*Z es el tamaño del paso se quiere hacer mientras que se ciclando a través del rango. |
− | + | Si te quiere un rango de valores de 1-10 y te quiere incrementar su valor por 2 cada vez que el comando se ejecutar, X Y Z debe ser 1 10 2. Cada vez que ejecutar, <argumento2> ejecutará con el valor incrementando de 2, 4, 6, 8, 10, 2, 4, 6, 8, 10, etc. | |
− | + | Eso es un ejemplo de incrementvar en acción: | |
:'''bind "n" "incrementvar net_graphpos 1 3 1"''' | :'''bind "n" "incrementvar net_graphpos 1 3 1"''' | ||
− | + | Eso se une el tecla "N" a ciclar a el posición siguiente en los tres posiciones disponibles del comando net_graph. | |
==The + and - commands== | ==The + and - commands== |
Revision as of 02:09, 29 November 2010
«¡Vamos a comportarnos como caballeros!» Esta página se ha marcado como artículo con una revisión abierta. Echa un vistazo a la página de discusión para ver información adicional o dar tu opinión. |
Los Scrips son configuraciones que crean nuevas entradas llamados "Binds" o "Alias".
- Los Binds consisten en enlazar un comando de la consola con una tecla, como por ejemplo una acción como disparas, o escribir automáticamente algo en el chat.
- Los Alias consisten en usar dos acciones a la vez con una sola tecla. El más común es el de saltar y agacharte a la vez con pulsar solo el Espacio.
Estos Scripts se pueden compartir, pero también los puede haber de creación propia, esto es lo que hace que sean distintos unos de otros. Con tiempo y esfuerzo puedes conseguir hacer lo que quieras con tansolo pulsar una sola tecla.
Índice
Archivos de Script Básicos
El Team Fortress 2 lee automaticamente los archivos del juego y ejecuta los Binds y Alias en ellos. Aquí hay una lista de ellos:
- config.cfg - Esta es la configuración por defecto, la cual se edita automaticamente cuando cambias algo desde el Menú de Opciones. Es mejor no editar este archivo.
- autoexec.cfg - Esta es la configuración por defecto, pero aplicada al uso de Binds y Alias. Aqui puedes poner los binds directamente, pero a veces es más sencillo hacer distintos archivos .cfg para cada script.
- <class>.cfg - Esta es la configuración por defecto de cada clase, la cual puedes editar para que los cambios ejercidos (Como viewmodel_fov, o sensibilidad de ratón sean solo en esa clase).
Sintaxis
Aqui una lista de las normas de la sintaxis:
- Para crear cualquier bind necesitas la siguiente estructura:
- comando <argumento1> <argument2o>
- El Comando es el tipo de script que usarás:
- bind - Usado para bindear una acción o texto a una tecla. (Por ejemplo: bind "f+use")
- alias - Usado para ejecutar comando cuando el alias es ejecutado. (Por ejemplo: alias space "space+ctrl")
- exec - Usado para ejecutar una configuarción que no se haya cargado. (Por ejemplo: exec etf2l)
- <argumento1> Es la tecla en la que quieres que se cree el bind o alias.
- <argumento2> Es la acción que hará.
- Para introducir más de un comando debes de ponerlo entre comillas y separado por un punto y coma (;)
Ejemplo:
- alias "spraynpray" "+attack; wait 500; -attack"
- bind "mouse3" "spraynpray"
- Cuando se ejecuto el jugador lanzará un cohete cada 500 FPS (lo que equivale a 5 segundos en un servidor que vaya a 100 FPS) y luego dejará de disparar. El alias se ejecutará cuando pulses Mouse 3 que es la rueda.
Comandos Básicos
La mayoría de los comandos se aceptar un argumento solo, que es un valor te querer ejecutar.
bind "q" "sv_alltalk 1"
Algunos de los comandos se aceptar argumentos múltiplos. Por ejemplo:
- disguise X Y - El Spy se disfraza. "X" es la clase 1-9 y "Y" es el equipo 1 or 2.
- voicemenu X Y - Ejecutar el comando de voz. "X" es el número de la menú primario. "Y" es el posición del comando en esa menú.
Por ejemplo: "voicemenu 1 1" es el comando para Spy:
bind "t" "voicemenu 1 1"
Este comando es para hacer su carácter se dice "Spy!" cuando se pulsa el tecla.
Incrementvar
Eso comando es para ciclar a través de un rango de valores cada vez que se ejecutar y se aplicar los valores a el otro comando. Hay el formo:
- comando "<argumento1>" "incrementvar <argument2> X Y Z"
- X y Y represente el rango de valores se quiere ejecutar con <argumento2>.
- Z es el tamaño del paso se quiere hacer mientras que se ciclando a través del rango.
Si te quiere un rango de valores de 1-10 y te quiere incrementar su valor por 2 cada vez que el comando se ejecutar, X Y Z debe ser 1 10 2. Cada vez que ejecutar, <argumento2> ejecutará con el valor incrementando de 2, 4, 6, 8, 10, 2, 4, 6, 8, 10, etc.
Eso es un ejemplo de incrementvar en acción:
- bind "n" "incrementvar net_graphpos 1 3 1"
Eso se une el tecla "N" a ciclar a el posición siguiente en los tres posiciones disponibles del comando net_graph.
The + and - commands
These commands have two states. While the bound key is pressed, the +command executes and continues to execute. When the key is released, the -command executes and continues to execute.
Example:
- bind "c" "+duck"
This +command is bound to "c" so whenever the key is pressed, the player ducks. Whenever the key is released, +duck is swapped to -duck and the player stops ducking.
In general, if a command or alias is bound to a key, a + tells the game to run the command as long as the key is held. Similarly, if a command or alias is bound to a key, a - tells the game to run the command when the key is released.
If an alias is defined with a + in front of it, the alias will be run whenever the key is pressed, as the key is pressed. The - command will then run as the key is released.
Wait Command
If you want the game to delay for a period of time during an alias, or if you want avoid client crashes caused by executing commands too quickly, use the wait command.
Wait tells the game to delay the next command in the script by one physics frame, something like a full turn in the TF2 rules. It accepts values such as "wait 50" which tells the game to wait fifty frames before the alias continues. "wait 100" is roughly a second on a 100 FPS server.
Some servers disable the wait command. While playing on them, wait commands will be ignored, making some scripts susceptible to crashes. A script containing an indeterminate loop spaced by wait commands will always immediately hang upon usage on such servers.
Aliases
An alias is like a variable that stores a series of commands which can be executed as a group. A simple alias will take the form:
alias "aliasname" "command1; command2; command3"
You can then execute the commands through a bound key:
bind "key" "aliasname"
Whenever the key is pressed, command1, command2, and command3 are executed in order.
Complex Aliases
Aliases can execute any command including other aliases. Furthermore, an alias can execute an alias in order to redefine that alias's commands. This allows you to create cycling aliases. Here is a very simple example:
bind "key" namescroll
alias namescroll "firstname"
alias firstname "setinfo name "First_name"; alias namescroll secondname"
alias secondname "setinfo name "Second_name"; alias namescroll thirdname"
alias thirdname "setinfo name "Third-name"; alias namescroll firstname"
This is difficult to read, so break it down.
- The first line binds "key" to an alias "namescroll" which we have yet to define.
- The second line creates the alias "namescroll" which executes the command "firstname"
- The third line defines the "firstname" alias as two commands:
- The first command sets your in-game name to "First_name"
- The second command redefines the alias "namescroll" as an alias for executing the alias "secondname"
- The fourth line defines "secondname" in the same manner. A different in-game name is set, and then "namescroll" is redefined to another alias "thirdname"
- The fifth line defines "thirdname" just like the two before it, but with a twist. It redefines the "namescroll" alias as executing the "firstname" alias.
This completes a loop. Each press of the key executes a command and redefines the alias bound to the key, so that when it is next pressed it will execute a different command. If there were no loop, then the alias "namescroll" wouldn't always have another alias to execute with each keypress.
Alias Loops
Aliases can be used in conjunction with the Wait command to create looping aliases.
Warning:Not having the wait in place, or being on a server with wait disabled will cause this example to crash TF2.
alias "Loop" "echo Looping every 150 ticks.;wait 150;Loop"
Loop
Lets break this down into components:
Line 1
The echo displays a message to the console, just so you know it works.
The wait makes it wait 150 ticks between iterations
Loop calls the alias again, restarting at the echo.
Line 2
Loop starts the looping alias.
You can also create loops of alias commands, like this example:
alias "Loop1" "echo Loop 1;wait 150;Loop2"
alias "Loop2" "echo Loop 2;wait 150;Loop1"
Loop1 calls Loop2 which in turn calls Loop1, etc...
This method can also be used for breaking a loop without clearing the loop alias:
alias "Loop1" "echo Loop1;wait 150;Loop2"
alias "Loop2" "Loop1"
This would create a loop, then
alias "Loop2"
would break it, by clearing the Loop2 alias.
You can use these for button presses(Via the +/- prefixes covered earlier) like this:
alias "Loop2" "Loop1"
alias "Loop1" "echo Loop1;wait 150;Loop2"
alias "+Loop" "alias Loop2 Loop1;Loop2"
alias "-Loop" "alias Loop2"
bind "<Key>" "+Loop"
In order of what it's doing:
Make Loop2 point to Loop1
Make Loop1 echo 'Loop1' to the console, wait 150, then call Loop2
make +Loop point Loop2 to Loop1 and run Loop2
make -Loop clear Loop2's link, breaking the loop
Useful Script Commands
There are literally hundreds of different arguments for your script that can make them do almost anything. Here's a list of a few of them.
Voice Commands
Voice command is the act of making your class say something, this is often used in gameplay as a way of either signaling information or just for goofing-off.
Voice commands are used with the following syntax;
voicemenu <menu_number> <phrase_number>
Where <menu_number> is the one of the 3 menus where voice commands are spread out through <phrase_number> is one of the 7 voice commands that are within each <menu_number> menu.
Arguments for voice commands
- 0 <phrase_number>
- 0: Medic
- 1: Thanks
- 2: Go
- 3: Move Up
- 4: Flank Left
- 5: Flank Right
- 6: Yes
- 7: No
- 1 <phrase_number>
- 0: Incoming
- 1: Cloaked Spy
- 2: Sentry Ahead
- 3: Teleporter Here
- 4: Dispenser Here
- 5: Sentry Here
- 6: Activate ÜberCharge
- 7: (Medic Only) ÜberCharge Ready
- 2 <phrase_number>
- 0: Help
- 1: Battlecry
- 2: Cheers
- 3: Jeers
- 4: Positive
- 5: Negative
- 6: Nice Shot
- 7: Good Job
Quick Spy disguises
With these quick and easy commands, you can bind keys to specific disguises instead of having to flip through the disguise menu.
Disguise commands are used with the following syntax;
disguise <class_number> <team_number>
Where <class_number> is the number of the class you wish to disguise as, and <team_number> the number of the team you wish to disguise as.
Arguments for disguise commands
- 1 <class_number>
- 1: Scout
- 2: Sniper
- 3: Soldier
- 4: Demoman
- 5: Medic
- 6: Heavy
- 7: Pyro
- 8: Spy
- 9: Engineer
- 2 <team_number>
- 1: BLU team
- 2: RED team
- -1: Opposite team
- -2: Same team
Noteworthy scripts
There are several notable scripts that have affected gameplay. Some of these are patched out. Others remain functional.
Patched Scripts
Pistol Script
Originally, the Pistol could be fired almost as fast as the human hand could press a key. Realizing this, some people created scripts that made the Pistol fire as rapidly as possible as long as you held down the fire button. This not only allowed the Scout and Engineer to fire faster than most people could manage, but it was easier to aim because you weren't mashing any keys.
Valve eventually leveled the playing field. They patched the Pistol to have a lower max firing rate, which was reached by default whenever a player held down the attack key. The Pistol script was no longer necessary.
Targe Turn Script
Originally, the keyboard commands to turn your viewpoint left and right were not treated the same as the mouse commands. The Chargin' Targe was the first weapon to create a restriction on how quickly you could turn your viewpoint, therefore Valve put a limit on mouse turn-speed but forgot to apply the same restriction to the keyboard command that resulted in the same action.
Players made scripts that rebound keys whenever a player charged, allowing them to turn at full speed. The most sophisticated examples temporarily rebound the mouse x-axis inputs to the keyboard turn commands, then unbound them when the player attacked at the end of the charge.
Valve eventually capped the keyboard turn commands as they did with the mouse commands, thus conferring no advantage to individuals who used the script.
Air Crouching Script
Originally, you could crouch as many times as you liked in a single jump. By binding a script to crouch and uncrouch as rapidly as possible, you could exploit the engine and make it difficult to properly register shots on jumping targets.
Valve patched it so you could only crouch twice in a single jump.
Current Scripts
Weapon Hiding Scripts
There are a large number of scripts which toggle the weapon display option depending on which weapon slot is selected for a class. Players often make their guns invisible to clear up the screen, but make items like Cuerpo a cuerpo weapons, PDAs, watches and so forth visible because these models indicate important information. For example, the Spy relies heavily on his visible model to determine when he is cloaked, when his Cloak is disturbed, and when the Dead Ringer activates. Other classes use the Cuerpo a cuerpo animations to judge when their attacks will hit.
Sentry Jumping Scripts
Since the Engineer update, Engineers have been able to pack up and carry their Sentry Guns. Simultaneously, the Wrangler allowed Engineers to Sentry jump with their Sentry rockets. With extremely fast inputs, it was discovered that a player could Sentry jump and successfully pack up their Sentry before they were launched away.
While a human can repeat this feat, it's difficult and sometimes inconsistent. Some players made scripts which could reliably execute the commands in the right order at the right speed. They can make a Sentry jump while carrying their Sentry every time.
Gunslinger Scripts
Since it can be troublesome to destroy then rebuild a Combat Mini-Sentry in the heat of battle through the PDA, some players have scripted the destruction and rebuilding of their Mini-Sentry with the click of one or two mouse buttons.
Sensitivity and Control Scripts
Some players prefer different mouse sensitivities and control schemes for some classes (for example, changing from Scout, which requires high sensitivity for quick turning and maneuverbility, to Sniper, which encourages low sensitivity for precise aiming so a hand twitching inadvertently won't ruin your aim too much). These scripts alter their control schemes and mouse settings on a per class or even per weapon basis.
Zoom Scripts
By temporarily changing field of view variables to a lower field of view, one can achieve a minor zooming effect. This can provide a minor precision and visibility advantage.
See Also
External Links
- Steam Users' Forums - TF2 Scripting Tutorial. This covers the basics of scripting, using numerous useful, approachable examples.
- TF2 scripting tutorial - Warrior Nation Network. This is a much more advanced article, which requires pre-requisite knowledge of the basic scripting syntax.
- FPSBanana.com - TF2 scripts. Hundreds of scripting examples for TF2.