Nasal Initialization

From FlightGear wiki
Revision as of 23:28, 6 January 2020 by Jsb (talk | contribs) (initial version)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.

Root directory / core modules

The nasal root folder (FGDATA/Nasal/) is scanned for .nas files. This 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, which have been just defined in the core modules, e.g. which were not available when parsing the files.

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 parsed, 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.

Open questions

Review the sources to confirm / update this doc.