Introduction

With the release of patch V in December 2006, the LFS developers introduced a new scripting system, quite similar to the implementation seen in most first person shooters. Generally, it allows the automation of common tasks, customisation of options on a per-car basis as well as simple toggles to change the binding of keys (and more). This guide is aimed to give you a general understanding of the LFS script system as well as a few examples for simple scripts.

How to use

Basics

Script files have the extension ".lfs" and can be found under <LFS install dir>\data\script. To edit these files, simply open them with a text editor of your choice (Notepad, etc). You can also create new script files, just make sure they have the right extension. If you want, you can even organize your scripts into subdirectories to keep the place clean.

In general, each line in the script file represents a command that is executed by LFS, going from top to bottom. The only exception are empty lines, and lines that start with "//", which are treated as comments and thus ignored. Basically you can imagine the system as LFS reading each line, writing it into the chat window and hitting return. Of course it is not exactly like that, but it should give you the general idea.

Reserved filenames

While you can generally name new script files however you want, a few names have a special meaning to LFS. All affected files already exist in the script folder when you first install the patch, so as long as you don't move or overwrite any files everything will be fine.

autoexec.lfs

Like the name suggests, this script is executed automatically every time LFS starts and is thus the ideal place to initialize your scripts.

CAR.lfs

"CAR" being replaced with one of the three-letter car shortcuts (see here or below), these scripts are executed everytime the corresponding car is selected in the garage - for example if you select the XR GT Turbo, LFS will execute "XRT.lfs". They are usually used for car specific settings, like a custom FOV or force feedback strength.

road.lfs, sequential.lfs, paddle.lfs

Even though these filenames are neither reserved nor automatically executed, they are worth mentioning as by default they are run from inside the CAR.lfs scripts. Their main purpose are custom settings that should apply to cars with a certain shifter type. Road.lfs is the equivalent to cars with a H-gate shifter, sequential.lfs to a sequential stick shifter and paddle.lfs to having paddles. If you have a wheel that supports such shifter types (like the Logitech G25 for example), then these script files are handy to automatically change the shifter setup so it fits the currently selected car.

To match the cars to their gearbox, they should be assigned as following:

Road:

UF1, XFG, XRG, XRT, RB4, FXO, LX4, LX6, FZ5, FZR, UFR, RAC

Sequential:

FBM, FOX, FO8, MRT, XFR, XRR, FXR

Paddle:

BF1

Commands

The following commands are just an excerpt of the more commonly used ones.
A list of all commands can be found under <LFS install dir>\docs\Commands.txt.

Examples

On a general note: as you might have noticed from the command listing, it is currently impossible to bind other script commands to a button; for example, "/button 1 /say hello" wouldn't work. Luckily we can use the text shortcut keys (Ctrl+F1-F12, Alt+F1-F12) for this, so we can use "/ctrlf 1 /say hello" (which binds "/say hello" to Ctrl+F1) and then "/button 1 ctrl_f1" (binds the press of Ctrl+F1 to button #1). However, this also means that you have to give away a few of your shortcut keys for the scripts, which shouldn't really be a problem, considering there are 32 available shortcuts total (24 bindable via scripts).

"F9 > F10 > F11 > F12 > Off" Toggle

Shortcut keys used: Ctrl+F12

The basic idea of this script is, that we want to have one button (for example on the wheel) cycling through the F9-F12 menus. To accomplish this, we need five scripts plus an entry in autoexec.lfs.

For this script we will use the Ctrl+F12 text shortcut for our cycle, and bind button #0 (whichever button that is on your controller) to execute it. The multiple usage of the /press command ensures that the menu is properly displayed, in case a menu was already opened manually beforehand. For example, if the F11 menu is already open and we would run viewF11.lfs without pressing the F9 key in it, it would just close the F11 menu instead, which is something we definitely don't want to happen in the heat of a race.

Indicator Control

Shortcut keys used: Ctrl+F10, Ctrl+F11

This example shows a simple way to comfortably control the indicators with two buttons. You need three scripts and a few entries to autoexec.lfs, shortcut keys used are Ctrl+F10 and F11. The indicators will work as follows; first press of left button activates left indicator, second press deactivates it. Vice versa for the right button. Switching between left and right is possible. For ease of use, the script will output green arrows indicating the currently selected mode into the chat area.

By using the same logic and adding another script, it is also easy to implement the control of the hazards by a third button.

Automatic shifter configuration (for Logitech G25/G27 users)

Shortcut keys used: None

To automatically adjust the controller bindings for the shift mechanism used by the currently selected car, all you have to do is modify the existing road.lfs, sequential.lfs and paddle.lfs as shown below.

Optionally you can also add re-bindings of whatever you want to use the free shifter/paddle buttons for. For example, when using the shifter unit, my right paddle acts as handbrake and the left one as horn, whereas when using the paddles, pulling the sequential stick is the handbrake and pushing sounds the horn. Doing this maximises the capabilities of the few easy-to-reach buttons on the G25; these re-bindings are not included in the example scripts.