20,741
edits
m (→Intro) |
|||
Line 48: | Line 48: | ||
== 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= | 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=774}}. | ||
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}}. | 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 | The following is a copy of the extension function list, taken in 11/2015: | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
// Table of extension functions. Terminate with zeros. | |||
static struct { const char* name; naCFunction func; } funcs[] = { | 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> | </syntaxhighlight> |