Moved syntax to its own page, added refs

main
Paco Hope 2022-08-15 09:04:49 -04:00
parent ac086e5894
commit 8a71aed1f8
1 changed files with 4 additions and 112 deletions

View File

@ -3,6 +3,8 @@ Welcome to TFScript
TFScript helps you manage all the customisations you make to your Team Fortress 2 configurations. If you have `custom scripts <https://wiki.teamfortress.com/wiki/Scripting_faq>`_ in your ``cfg`` files, then this will help you automate that.
TFScript uses YAML to express how you want your keybindings to work. It helps you organize your bindings. It lets you put all the keybindings for all your classes into a single file. It lets you set some basic defaults that then get copied into every class so you can count on them all the time. Once you've got a good YAML file describing your favorite keybindings, you can manage all your bindings from that single file.
Basic overview
====================================
@ -10,121 +12,11 @@ TFScript is meant to simplify the complexity of creating tf2 keybinds. While sim
The basic process for creating a TFScript config file goes as such:
1. Write your TFScript file according to the <u>Syntax Guide</u>
1. Write your TFScript file according to the :ref:`syntax-page` guide
2. Run ``TFScript <filename>`` to generate code and write to game files
3. Play tf2 with your new binds!
A TFScript file is written in YAML and parsed by the program to generate the apporpriate code, so if you know the YAML syntax you can jump straight to the <u>TFScript Syntax</u> section, otherwise, read the <u>YAML Syntax</u> section below, *then* read the <u>TFScript Syntax</u> section.
TFScript Syntax
===================
A TFScript file is structured like this
.. code-block::
:caption: Basic tfscript input file
class1:
key1:
type:
fields
key2:
type:
fields
...
class2:
key1:
...
where ``class1``, ``class2``, etc. refer to classes such as soldier, pyro, or any of the other lovable mercenaries.
``key1`` and ``key2`` are keys such as ``w`` or ``mouse1`` to which you want actions bound, and ``type``/``fields`` is the data to be parsed by TFScript to generate a config file.
Classes
----------------
The full list of valid class names is as follows:
* Scout
* Soldier
* Pyro
* Demo
* Heavy
* Engi
* Medic
* Sniper
* Spy
* Default
As you may have noticed, there is a special class, "default", which specifies the default state of any and all keys. Any keybinds in this config are the defaults, and apply to all other classes unless specifically overwritten (that said, any classes which *do* have a different definition for that key will overwrite the previous "default" definition).
Names are not case sensitive, so "SoLDiER" will work just as well as "soldier".
Keys
^^^^^^^^^^^^^^^^^
If you are already familiar with TF2 scripting, every key that tf2 recognizes is also recognized by TFScript.
For the rest of us, the most relavent keys are:
* A to Z
* 0 to 9
* space
* tab
* capslock
* shift
* ctrl
* function
* alt
For the remaining symbol characters (like "\`", "[", or "\\"), just press the key that it appears on, on your keyboard. *Do not* hold shift, alt, or any other control keys. This does limit the keys you can use, for example if you wanted to use the \{ character, you would be stuck with \[. This is a limit imposed by TF2, but you can get around this using the ``double`` type, as explained later.
Some examples
==========================
For example, this config will bind "e" to call for medic, unless mouse4 is held, in which case it will call for an ÜberCharge:
.. code-block::
:caption: Example tfscript for binding ubercharge:
alias call_for_medic "voicemenu 0 0"
alias call_for_uber "voicemenu 1 6"
alias e_bind call_for_medic
bind e e_bind
alias +toggle_state "alias e_bind call_for_uber"
alias -toggle_state "alias e_bind call_for_medic"
bind mouse4 "+toggle_state"
There are some issues with this:
* It is quite verbose, and if several of these exist the file can become difficult to traverse
* There is a lack of clarity in the voicemenu command, only the bind name explains what it does
* If either "mouse4" or "e" had a prior function, it has now been overwritten
* The scope is dictated by what ``.cfg`` file this is located within, which can cause problems
The TFScript way of doing this is:
.. code-block::
:caption: Basic tfscript input file
default:
e:
double:
primary:
impulse: voice medic
secondary:
impulse: voice activate uber
condition: mouse4
There are several benefits to this:
* The indentation allows for easier scanning of the file
* The voicemenu commands have been replaced with the clearer "voice" impulse
* Since this is within the ``default`` section, it is clear that there are is no "prior function" to overwrite and this will apply to all classes unless specifically overwritten.
A TFScript file is written in YAML and parsed by the program to generate the apporpriate code, so if you know the YAML you can jump straight to the :ref:`syntax-page` page, otherwise, read the :ref:`yaml-page` page first, *then* read the :ref:`syntax-page` page.
Known issues, problems, etc.
=================================