| The FlightGear forum has a
subforum related to: Nasal Scripting
|Memory Management (GC)|
The Nasal Console built into FlightGear is quite handy when it comes to debugging code. However, here the namespaces need to be considered. In addition, Nasal sub modules (see above) have some special rules, too - basically, all Nasal files part of a "sub module" share a single name space based on the folder's name rather than the name of the individual Nasal files.
For cases of Nasal code specific for an aircraft (like instruments, for example), the corresponding scripts could be loaded through the aircraft's -set.xml file by putting it into the <nasal>...</nasal> section
<nasal> ... <moduleA> <file>path/to/file1.nas</file> <file>path/to/file2.nas</file> </moduleA> <moduleB> <file>path/to/file3.nas</file> </moduleB> </nasal>
In this case, variables in files path/to/file1.nas and path/to/file2.nas can be used in the Nasal console as
Variables in path/to/file3.nas can be accessed as
Please note that Nasal sub modules (i.e. files loaded and run from their own Nasal sub directory), are subject to some special rules, as all Nasal source files are automatically loaded into the same namespace, which is by default based on the sub module's folder name. See Creating new Nasal scripts#Nasal sub modules for more information.
Nasal embedded in XML files
Various XML files support embedded Nasal code inline, these will be loaded into special namespaces. For example:
- gui dialogs: prepend "__dlg:" and use the module's name (or "[unnamed]") as the suffix, e.g. "__dlg:nasal-console" or "__dlg:exit"
- joystick files: prepend "__jsN"
- keyboard files: prepend "__kbd"
For more info see 
More information can be found at Namespaces and Methods.