Nasal Initialization: Difference between revisions

Jump to navigation Jump to search
m
Line 10: Line 10:
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.
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.


== Optional load-once modules ==
== Optional (load-once) modules ==
After the files in the root directory have been processed, the first level of subdirectories is scanned for .nas files.
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,  
Each subdirectory defines a module / namespace which becomes available only after the files in the subdirectory have been completly processed,  
Line 21: Line 21:


=== Enabling of load-once modules ===
=== Enabling of load-once modules ===
Enabling / loading of this modules is done in the C++ code and is a little bit complicated (see FG sources /src/Scripting/NasalSys.cxx).
From the user (aircraft developer) point of view, enabling of this modules is done by setting the property {{code|/nasal/<moduleName>/enabled}} to {{code|true}}.
 
If a module is needed by an aircraft, you can just add the following to your aircraft-set.xml file (replace ''module_name'' by the name of the desired module):
<syntaxhighlight lang="xml">
<PropertyList>
    <nasal>
        <module_name>
            <enabled type="bool">true</enabled>
        </module_name>
    <nasal>
</PropertyList>
</syntaxhighlight>
Loading  is done in the C++ code and is a little bit complicated (see FG sources /src/Scripting/NasalSys.cxx).
''FGNasalSys::init()'' scans FGDATA/Nasal for subdirectories and calls ''FGNasalSys::addModule()'' for each subdirectory passing its name as module name and a list of all .nas files in it.
''FGNasalSys::init()'' scans FGDATA/Nasal for subdirectories and calls ''FGNasalSys::addModule()'' for each subdirectory passing its name as module name and a list of all .nas files in it.


252

edits

Navigation menu