Nasal Initialization

From FlightGear wiki
Revision as of 08:46, 20 February 2020 by Jsb (talk | contribs) (→‎Core modules)
Jump to navigation Jump to search

some notes on how Nasal files from FGDATA/Nasal appear to be processed when Flightgear is started.

Initialization of Nasal core-/default-modules

When Flightgear starts, it will start the Nasal parser and load modules from FGDATA/Nasal.

Core modules

The nasal root folder (FGDATA/Nasal/) is scanned for .nas files and these files are loaded (apparantly in alphabetical order). After all .nas files are loaded /sim/signals/nasal-dir-initialized is set, which triggers listeners in some of the files just loaded. This allows to use functions from other core files, which have just been defined, e.g. which were not yet available when parsing the file.

Sub-directories

After the files in the root directory have been processed, the first level of subdirectories is scanned for .nas files. Each subdirectory defines a module / namespace which becomes available only after the files in the subdirectory have been completly processed, e.g. a variable foo in module bar becomes available as bar.foo only after parsing of the respective folder.

Sub-sub-directories will not be scanned for .nas files - at least not automatically on FG startup. Of course, files of sub-sub-directories can be included (sooner or later) by the Nasal code that is being processed, so optional code can be loaded on demand.

Enabling / Disabling modules

There is a mechanism to enable/disable modules in the C++ domain (in FGNasalSys), however, at the time of writing, the state of this mechanism is unclear. This section shall be updated once the desired design as well as the implementation has been clarified.


Open questions

Review the sources to confirm / update this doc.