277
edits
No edit summary  | 
				|||
| Line 244: | Line 244: | ||
var bar = foo.get("bar"); # get variable "bar" defined in FGDATA/Nasal/modules/foo/main.nas (or a file included by this file)  | var bar = foo.get("bar"); # get variable "bar" defined in FGDATA/Nasal/modules/foo/main.nas (or a file included by this file)  | ||
}}  | }}  | ||
= Property tree interface for modules.nas =  | |||
In the property tree there is a subtree /nasal to control modules and get some statistics.  | |||
The properties available depend on the type of module ("load-once" or "reloadable", see [[Nasal Initialization]] for more information on the differences).  | |||
== Reloadable modules / frameworks ==  | |||
Modules handled by modules.nas will have their properties in /nasal/modules/<moduleName> where <moduleName> is given by the developer when calling either   | |||
{{code|Module.new("<moduleName>")}} or {{code|modules.load("<moduleName>")}}.   | |||
In the latter case <moduleName> specifies the subdirectory FGDATA/Nasal/modules/<moduleName> in which some framework is stored.  | |||
{| class="wikitable"  | |||
|-  | |||
! property !! type !! content  | |||
|-  | |||
| loaded || bool || true if module was loaded without errors  | |||
|-  | |||
| reload || bool || set this to true to trigger reload  | |||
|-  | |||
| listeners || int || Number of tracked listeners  | |||
|-  | |||
| listener-hits || int || If debugging is enabled, this prop shows the total number of hits to all tracked listeners.  | |||
|-  | |||
| timers || int || Number of tracked timers (maketimer).  | |||
|}  | |||
== Legacy load-once modules ==  | |||
A legacy load-once module is a direct (1st level) subdirectory of FGDATA/Nasal/ and its corresponding property tree is /nasal/<moduleName>/ where <moduleName> equals the name of the subdirectory.   | |||
It is handled by C++ code and must have a corresponding entry in FGDATA/defaults.xml which defines a property "enabled" and optionally a property "module".  | |||
If enabled is set to false in defaults.xml, the C++ code will setup a listener and load the module as soon as enabled is set to true.  | |||
The property name "module" is a bit misleading, it is used to define into which namespace the files shall be loaded.  | |||
For each .nas file in the subdirectory a file[i] property is created holding the full path+filename.  | |||
The bool "loaded" property shows the status of the module.  | |||
= Existing modules with reload support =  | = Existing modules with reload support =  | ||
edits