Howto:Write simple scripts in Nasal

From FlightGear wiki
Revision as of 10:14, 22 August 2007 by Ajmacleod (talk | contribs) (begin the tutorial)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

Creating the nasal file: As with many other things in FG, nasal functions can live in many different places. Here, however, we're going to create a "Systems" directory under the Main fokker50 directory. Later, other files might be added to this directory; an electrical system, functions to control other cockpit indicators, etc.

Within that new fokker50/Systems directory then, create an empty plain text file, we'll call it "degftodegc.nas". Note that many different functions can live in the same .nas file; this could be renamed to something more generic later if other similar functions are added to it in time.

Now, as always add a helpful comment at the top of the file;

# Converts degF to degC