20,741
edits
m (xml syntax highlighting) |
m (copy/paste my forum response here http://flightgear.org/forums/viewtopic.php?f=30&t=16089) |
||
Line 2: | Line 2: | ||
Aircraft that provide support for these scripted tutorials can be found in http://wiki.flightgear.org/index.php/Category:Interactive_Tutorial_Support | Aircraft that provide support for these scripted tutorials can be found in http://wiki.flightgear.org/index.php/Category:Interactive_Tutorial_Support | ||
== Some Background Info == | |||
The tutorial system itself was largely developed by Stuart: http://wiki.flightgear.org/Tutorials | |||
In recent FGDATA, the Nasal "tutorial" module has become a so called "Nasal sub module", which means that the "tutorial.nas" module now resides in its own sub folder inside $FG_ROOT/Nasal: http://gitorious.org/fg/fgdata/trees/master/Nasal/tutorial | |||
Support for Nasal sub modules was added by ThorstenB. Modules loaded as Nasal sub modules do automatically support reloading, because they are loaded via a listener. | |||
Please see the Nasal documentation on sub modules for details: http://wiki.flightgear.org/Nasal#Nasal_sub_modules | |||
Regarding suggested coding practices, you should check out: http://wiki.flightgear.org/Nasal_scripting_language#Memory_management and http://wiki.flightgear.org/Nasal#Managing_timers_and_listeners[/quote] | |||
== Reloading XML tutorials at runtime == | |||
tutorial.nas module is loaded via a listener ("/nasal/tutorial/loaded"). | |||
See line 28-37 of tutorial.nas in $FG_ROOT/Nasal/tutorial to see how this is done. | |||
Before you can actually reload a tutorial, you must first of all STOP it. | |||
Please see line 112-122 of tutorial.nas in $FG_ROOT/Nasal/tutorial. | |||
Once you have stopped all running tutorials, you can reload the corresponding tutorial. | |||
Please see line 477-480 of tutorial.nas in $FG_ROOT/Nasal/tutorial to see how this is done. | |||
Basically, you should be able to come up with your own "reload" function by combining the stop() and the load() functions and adding a new "reload" function to tutorial.nas: | |||
<syntaxhighlight lang="php"> | |||
var reload = func(filename,slot) stopTutorial() and load(filename,slot); | |||
</syntaxhighlight> | |||
Also, see line 450-463 of tutorial.nas in $FG_ROOT/Nasal/tutorial to see how the namespace is initialized. | |||
For additional information on namespace, I suggest to have a look at: http://wiki.flightgear.org/Namespaces_and_Methods | |||
== Using tutorials == | |||
Tutorials can be started and stopped from the "Help" [[menubar|menu]]. They are defined in XML files. Each of them has to be loaded into <tt>/sim/tutorials/</tt> under a separate <tt>tutorial[n]/</tt> branch: | Tutorials can be started and stopped from the "Help" [[menubar|menu]]. They are defined in XML files. Each of them has to be loaded into <tt>/sim/tutorials/</tt> under a separate <tt>tutorial[n]/</tt> branch: |