Changes

Jump to: navigation, search

Howto:Extend Nasal

37 bytes added, 15:29, 15 November 2015
m
Intro
== Intro ==
In FlightGear, the simplest way to add new extension functions is to look at the existing functions at {{flightgear file|src/Scripting/NasalSys.cxx|l=747774}}.
There is a static table of function pointers (named funcs[]) referencing extension functions, along with their corresponding names in Nasal: {{flightgear file|src/Scripting/NasalSys.cxx|l=482}}.
The following is a copy of the extension function list, taken in 1211/20142015:
<syntaxhighlight lang="cpp">
// Table of extension functions. Terminate with zeros.
static struct { const char* name; naCFunction func; } funcs[] = {
{ "getprop", f_getprop }, { "setprop", f_setprop }, { "print", f_print }, { "logprint", f_logprint }, { "_fgcommand", f_fgcommand }, { "settimer", f_settimer }, { "maketimer", f_makeTimer }, { "_setlistener", f_setlistener }, { "removelistener", f_removelistener }, { "addcommand", f_addCommand }, { "removecommand", f_removeCommand }, { "_cmdarg", f_cmdarg }, { "_interpolate", f_interpolate }, { "rand", f_rand }, { "srand", f_srand }, { "abort", f_abort }, { "directory", f_directory }, { "resolvepath", f_resolveDataPath }, { "finddata", f_findDataDir }, { "parsexml", f_parsexml }, { "parse_markdown", f_parse_markdown }, { "md5", f_md5 }, { "systime", f_systime }, { 0, 0 }
};
</syntaxhighlight>
18,391
edits

Navigation menu