4.6 KiB
Welcome to TFScript
TFScript helps you manage all the customisations you make to your
Team Fortress 2 configurations. If you have custom
scripts in your cfg
files, then this will help you
automate that.
Basic overview
TFScript is meant to simplify the complexity of creating tf2 keybinds. While simple binds may be easy, more complex actions such as key combinations and toggles can be quite complex.
The basic process for creating a TFScript config file goes as such:
- Write your TFScript file according to the <u>Syntax Guide</u>
- Run
TFScript <filename>
to generate code and write to game files - 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
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:
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:
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.
Known issues, problems, etc.
none everything is perfect and there are no problems it is all amazing