Howto:Write simple scripts in Nasal: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
'''Introduction:'''
'''Introduction:'''
Nasal is a scripting language available in FlightGear which opens up a world of possibilities for aircraft modellers.  Here, as an example, we will create a script to convert engine temperatures from degF to degC, as required by the Fokker50 instruments.
Nasal is a scripting language available in FlightGear which opens up a world of possibilities for aircraft modellers - much more detailed information can be found elsewhere [[Nasal_scripting_language]].  Here, though, as a simple example to get you started, we will create a very basic script to convert engine temperatures from degF to degC, as required by the Fokker50 instruments.
 
Such a script should ideally be very generic so that it can be reused easily; but the script here is deliberately kept as simple as possible.


'''Creating the nasal file:'''
'''Creating the nasal file:'''
Line 71: Line 73:


This listens for the fdm-initialized property to be set (this will happen when the sim has started up), and starts our convertTemp function when that happens.
This listens for the fdm-initialized property to be set (this will happen when the sim has started up), and starts our convertTemp function when that happens.
As an "exercise for the reader" (I always hate those!) you should make the script also convert the temperature values for the second engine.
Now you should be able to take advantage of the more detailed information available about nasal here on the wiki, at www.plausible.org/nasal , and also other pre-existing nasal scripts which can be useful to borrow from!
57

edits

Navigation menu