Skip to content
derammo edited this page Mar 28, 2020 · 5 revisions

Lua is a script language that is used in a number of different contexts where you may encounter it, and this can be confusing. This page will try to enumerate where Lua is used in a Helios environment.

DCS

DCS uses (as of DCS 2.5.5) Lua 5.1 as its main script language.

DCS uses Lua as configuration

Several of the important configuration files in DCS are actually Lua script files. Most importantly for Helios profiles, the Monitor Setup files are actually Lua scripts. These scripts are executed in a very limited Sandbox that allows only access to certain variables from the screen configuration and each such script sets up a number of globals that are then discovered by DCS.

DCS uses Lua as a script language

A lot of the aircraft cockpits, and some systems, are implemented in Lua. DCS calls out to Lua files in its installation directories to allow for customization and sometimes to do all the work in Lua. These files are run in different Lua "sandboxes" so they can't always communicate with each other and you should not expect to be able to access the same objects in all such files. Consult a DCS modding Discord or Forum to learn the dark magicka required.

DCS uses Lua as a mission script language

Non-trivial DCS mission files will include Lua code to react to events and otherwise go beyond what can be done with the triggers and actions that are built into the mission editor. Missions are run in a sandbox that can access the state of all objects in the world and the contents of the mission file, but not the cockpit instruments of a specific player. These scripts run on the server in a multi-player environment and do not have anything to do with Helios.

DCS uses Lua to provide extension APIs

The most important use of Lua for DCS extensions is the export.lua script point. DCS will read this file only on DCS restart, but execute it each time a world/mission is loaded and started. This file is executed in a specific sandbox that is different from the mission sandbox and is very well understood. This file will generally declare a set of global functions will well known names as callbacks. DCS will then call these callbacks on each frame rendered or on a timer. In these callbacks, Helios' export script code will gather all the information about what is changed in the cockpit and send it to the Helios Control Center over UDP. It will also react to commands such as "press this button" received from Control Center and execute those commands in DCS.

[add links here to export lua sandbox info]

Helios

A completely different use of Lua is the use in Helios itself. A Binding in Helios can be configured to use a Lua script to calculate the actual value to use when the binding is triggered. Helios profiles will include (hopefully very small) snippets of Lua code to do these mappings. Helios (as of version 1.4.2020.0315) uses Lua 5.3 to execute this code. It has nothing to do at all with the Lua usage in DCS and even in Helios' own export.lua scripts. Note that this Lua language version is quite different from the Lua version used in DCS and there are significant differences in the language. However, Helios Profiles should not use complex enough Lua scripts for this to matter. In case it does, please use the Lua documentation for the exact version of Lua used in Helios.

Clone this wiki locally