Nasal Snippets

From FlightGear wiki
Jump to navigation Jump to search
This article is a stub. You can help the wiki by expanding it.

This page is meant to collect commonly used or otherwise useful Nasal snippets for use in FlightGear. Ideally, this will help new users to get started programming in Nasal more easily.

If you have any Nasal specific questions, you will want to check out Nasal FAQ. Feel free to ask new questions, help answer, refine existing ones.

Calling a function with named arguments

var sayHello = func(name) {
 print("Hello ", name);
}

sayHello(name: "FlightGear");


Dumping all keys in a hash

var dump_keys = func(hash) {
    if (typeof(hash) != "hash") die("dump_keys(): Error! Argument is not a hash.");
    foreach(var key; keys(hash)){
        print(key, ": ", typeof(hash[key]));
    }
}