Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Changes

Jump to: navigation, search

Howto:Extend Nasal

103 bytes added, 10:32, 11 December 2014
Intro: updated
= Intro =
In FlightGear, the simplest way to add new extension functions is to look at the existing functions in {{Git file|gitorious|fg/flightgear|next|src/Scripting/NasalSys.cxx|482747|pre=$FG_SRC/}}.
There is a static table of function pointers (named funcs[]) referencing extension functions, along with their corresponding names in Nasal: {{Git file|gitorious|fg/flightgear|next|src/Scripting/NasalSys.cxx|482|pre=$FG_SRC/}}
The following is a copy of the extension function list, taken in 0512/20092014:
<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 }, { "parsexmlresolvepath", f_parsexml f_resolveDataPath }, { "systimefinddata", f_systime f_findDataDir }, { "carttogeodparsexml", f_carttogeod f_parsexml }, { "geodtocartparse_markdown", f_geodtocart f_parse_markdown }, { "geodinfomd5", f_geodinfo f_md5 }, { "airportinfosystime", f_airportinfo f_systime }, { 0, 0 } };
</syntaxhighlight>
5
edits

Navigation menu