Howto:Nasal in scenery object XML files: Difference between revisions
Jump to navigation
Jump to search
(This is not implemented yet in FlightGear!) |
|||
Line 2: | Line 2: | ||
{{WIP}} | {{WIP}} | ||
(As of 05/2009, this is work in progress and entirely based on [http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg01757.html]). | (As of 05/2009, this is work in progress and entirely based on [http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg01757.html]). | ||
There's now support for embedding Nasal code (scripts) into object XML files. | |||
This can be used for 'intelligent' objects -- such as for example special lighting features, specific lighthouse signals, things that couldn't be done with animations alone. | This can be used for 'intelligent' objects -- such as for example special lighting features, specific lighthouse signals, things that couldn't be done with animations alone. |
Revision as of 17:59, 13 May 2009
This article is a stub. You can help the wiki by expanding it. |
Work in progress This article or section will be worked on in the upcoming hours or days. See history for the latest developments. |
(As of 05/2009, this is work in progress and entirely based on [1]).
There's now support for embedding Nasal code (scripts) into object XML files.
This can be used for 'intelligent' objects -- such as for example special lighting features, specific lighthouse signals, things that couldn't be done with animations alone.
The code is run as soon as the tile loader decided to load the model. It can use listeners and timers and so run as long as it wishes. If the object is removed from memory, then a variable is changed in the object's namespace, so that the code can stop itself. An optional destructor part can be used for further cleanup (remove listeners etc.)
It is using two properies <load> and <unload>. Example:
<?xml version="1.0"?> <PropertyList> <path>helipad.ac</path> <nasal> <load> loaded = 1; print("Hello, I'm the helipad!"); var f = func { if (!loaded) { return } print("I'm still there!"); settimer(f, 5); } f(); </load> <unload> loaded = 0; print("Bye, bye!") </unload> </nasal> <animation> <type>noshadow</type> <object-name>helipad</object-name> </animation> </PropertyList>