FlightGear Newsletter July 2010: Difference between revisions

Jump to navigation Jump to search
m
"Nasal for newbies"
m (→‎Scenery corner: dublin, some typos to be ironed on the whole news)
m ("Nasal for newbies")
Line 69: Line 69:
Last month, the infamous [http://wiki.flightgear.org/index.php/Howto:_Get_rid_of_common_errors#Warning:_Picked_up_TriangleIntersect QNaN errors] that may cause FlightGear to become [[Showstoppers|unresponsive]] have been linked to potential issues in the Nasal interpreter (and more generally Nasal code) by flug, for more details please see: [http://www.flightgear.org/forums/viewtopic.php?f=18&t=8483&p=83701 "Nasal source of Dreaded Triangle Error-source of many probs?"].
Last month, the infamous [http://wiki.flightgear.org/index.php/Howto:_Get_rid_of_common_errors#Warning:_Picked_up_TriangleIntersect QNaN errors] that may cause FlightGear to become [[Showstoppers|unresponsive]] have been linked to potential issues in the Nasal interpreter (and more generally Nasal code) by flug, for more details please see: [http://www.flightgear.org/forums/viewtopic.php?f=18&t=8483&p=83701 "Nasal source of Dreaded Triangle Error-source of many probs?"].
For the time being, you will want to look out for any Nasal code that contains unchecked divisions with unvalidated divisors.
For the time being, you will want to look out for any Nasal code that contains unchecked divisions with unvalidated divisors.
== Nasal for newbies ==
[[Nasal]] is the name of FlightGear's built in scripting language that allows people to easily create custom logics for adjusting and driving FlightGear internals without having to modify the C++ source code or recompile FlightGear.
To use Nasal you don't need to be a programmer, in fact Nasal is so simple that it can be used by people without any prior programming experience at all. Still Nasal is very powerful and flexible.
Nasal scripts can be used for doing many interesting things.
Some of the more recent examples being the bombable addon, the local weather system or the seeking AI missiles, all of which are purely implemented as Nasal scripts.
You can see for yourself how easy it is to get started writing Nasal scripts:
Just create a new plain text file (using an editor like notepad on Windows) named "hello.nas" in the $FG_ROOT/Nasal directory, paste the following contents:
print("My first Nasal script !");
Watch the black shell window when starting FlightGear and you'll see the "My first Nasal script !" being printed to the console.
As you have surely noticed, all Nasal scripts in the $FG_ROOT/Nasal directory get loaded and run automatically during FlightGear startup.
The sample program just consists of one instruction, namely "print". Which is a function call to the built-in "print" function of the Nasal interpreter.
The print function can not only print strings, but also numbers or individual characters.
Function calls in Nasal always look like this:
name();
Where "name" would be the function's Nasal name, and then parentheses contain all parameters that you want to pass to the function. The expression is terminated using a semicolon.
To pass arguments to the function, you would simply add these in between the parentheses and separate them using a comma:
print(100, 200, 300);


==In the hangar==
==In the hangar==

Navigation menu