Skip to content

Create your lua file

Charlie edited this page Sep 24, 2023 · 14 revisions
  • Create your *.lua file in folder Scripts\DCS-BIOS\lib\modules\aircraft_modules\.
  • Open up an existing lua and use it as an example.

Header

We will use P-51D (P-51D.json) as an example :

module("P-51D", package.seeall)

local Module = require("Module")

--- @class P-51D : Module
local P_51D = Module:new("P-51D", 0x5000, { "P-51D", "TF-51D", "P-51D-30-NA" })
  • P-51D is the DCS-BIOS Module Name, also the file name.
  • The 0x5000 is the base address for this module, this must not collide with other modules. A new address can be found from addresses.txt in the doc folder.
  • "P-51D", "TF-51D", "P-51D-30-NA" These are Digital Combat Simulator's identifiers for the airplanes. In this case they are variants of the P-51D. This DCS-BIOS module will be loaded if any of those planes are flown. By keeping them all in the P-51D.lua the DCS-BIOS module is easier to maintain. Usually there is only the one entry.
  • P_51D is the local lua object name.

Footer

The file must return the local lua object in the end of the file as such :

return P_51D

Anything between Header and Footer

That is where you add your controls, digging into DCS files, using ModelViewer2.exe and test, test, test. It takes times and no two DCS modules are the same.

Back