Howto:Create a new Nasal module: Difference between revisions
Jump to navigation
Jump to search
m (moved Howto: Create a new Nasal module to Howto:Create a new Nasal module: Robot: Moved page) |
m (to let people know it won't print to the simulator screen, just the console screen) |
||
Line 3: | Line 3: | ||
Status: Planning | Status: Planning | ||
Last updated: | Last updated: 5/25/2012 | ||
Authors: Hooray | Authors: Hooray, rico001 | ||
References: | References: | ||
Line 27: | Line 27: | ||
This piece of code defines a new function named "mycode" that just prints a message to the console. | This piece of code defines a new function named "mycode" that just prints a message to the console. | ||
''Note: This code does not print or output anything to the window of the Flightgear simulator screen, only the console window).'' | |||
The _selistener call at the end of the snippet waits for the Nasal system to be initialized before the "mycode" function gets called. | The _selistener call at the end of the snippet waits for the Nasal system to be initialized before the "mycode" function gets called. | ||
[[Category:Nasal howto|Module, Create a new Nasal]] | [[Category:Nasal howto|Module, Create a new Nasal]] |
Revision as of 18:45, 25 May 2012
This article is a stub. You can help the wiki by expanding it. |
Status: Planning
Last updated: 5/25/2012
Authors: Hooray, rico001
References:
This tutorial will document all the steps involved in creating a new Nasal module, Nasal is FlightGear's scripting language.
- create a new plain text file under $FG_ROOT/Nasal/MODULE.nas
- replace MODULE with the name for your new module (for example, use "test")
- paste the following code into this file using a text editor (such as notepad on Windows)
# test.nas (save in $FG_ROOT/Nasal)
var mycode = func {
print("My test module got loaded !");
}
_setlistener("/sim/signals/nasal-dir-initialized", mycode);
This piece of code defines a new function named "mycode" that just prints a message to the console.
Note: This code does not print or output anything to the window of the Flightgear simulator screen, only the console window).
The _selistener call at the end of the snippet waits for the Nasal system to be initialized before the "mycode" function gets called.