Nasal Initialization: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
mNo edit summary
Line 25: Line 25:


''FGNasalSys::addModule()'' in turn creates property nodes for each file like ''/nasal/<moduleName>/file[i] = <filename>''
''FGNasalSys::addModule()'' in turn creates property nodes for each file like ''/nasal/<moduleName>/file[i] = <filename>''
{{caution|
{{caution| For each subdirectory there SHALL be an entry in FGDATA/defaults.xml defining the default state of the module. }}
For each subdirectory there SHALL be an entry in FGDATA/defaults.xml defining the default state of the module. }}


{{warning|
{{warning| At the time of writing addModule() creates ''/nasal/<moduleName>/enabled'' and sets it to ''true'' if it was not defined in defaults.xml. This is about to be corrected.}}
At the time of writing, addModule() creates ''/nasal/<moduleName>/enabled = true'' if it was not defined in defaults.xml.  
This is about to be corrected }}


init() continues, sets the property ''/sim/signal/nasal-dir-initialized'' to true and calls ''FGNasalSys::loadPropertyScripts()''
init() continues, sets the property ''/sim/signal/nasal-dir-initialized'' to true which will trigger listeners in some of the previously loaded Nasal files.


''FGNasalSys::loadPropertyScripts()'' checks ''/nasal/<moduleName>/enabled''. If it is true, the files will be loaded by calling ''FGNasalSys::loadModule()'' which in turn calls ''FGNasalSys::createModule()''.  
Next it calls ''FGNasalSys::loadPropertyScripts()'' which checks all the ''/nasal/<moduleName>/enabled'' nodes. If true, the files will be loaded by calling ''FGNasalSys::loadModule()'' which in turn calls ''FGNasalSys::createModule()''.  


Otherwise a listener is added that will load the module when enabled is set to true.
Otherwise, if enabled is false, a listener is added that will load the module when enabled is set to true.
{{note|The module name (which defaults to the name of the subdirectory) is also the name of the Nasal name space in which functions and variables will be created.
If the name space already exists, the module will add to it so you can extend existing libs. But be very careful when overloading existing things, you can easily break things.}}


= Open questions =
= Open questions =
Review the sources to confirm / update this doc.
Review the sources to confirm / update this doc.
252

edits

Navigation menu