Howto:Extend Nasal: Difference between revisions

Jump to navigation Jump to search
→‎Intro: updated
(→‎Intro: updated)
Line 52: Line 52:


= Intro =
= 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|482|pre=$FG_SRC/}}.
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|747|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/}}
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 05/2009:
The following is a copy of the extension function list, taken in 12/2014:


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
   // Table of extension functions. Terminate with zeros.
   // 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 },
  { "getprop", f_getprop },
    { "setprop",   f_setprop },
  { "setprop", f_setprop },
    { "print",     f_print },
  { "print", f_print },
    { "_fgcommand", f_fgcommand },
  { "logprint", f_logprint },
    { "settimer", f_settimer },
  { "_fgcommand", f_fgcommand },
    { "_setlistener", f_setlistener },
  { "settimer", f_settimer },
    { "removelistener", f_removelistener },
  { "maketimer", f_makeTimer },
    { "_cmdarg", f_cmdarg },
  { "_setlistener", f_setlistener },
    { "_interpolate", f_interpolate },
  { "removelistener", f_removelistener },
    { "rand", f_rand },
  { "addcommand", f_addCommand },
    { "srand", f_srand },
  { "removecommand", f_removeCommand },
    { "abort", f_abort },
  { "_cmdarg", f_cmdarg },
    { "directory", f_directory },
  { "_interpolate", f_interpolate },
    { "parsexml", f_parsexml },
  { "rand", f_rand },
    { "systime", f_systime },
  { "srand", f_srand },
    { "carttogeod", f_carttogeod },
  { "abort", f_abort },
    { "geodtocart", f_geodtocart },
  { "directory", f_directory },
    { "geodinfo", f_geodinfo },
  { "resolvepath", f_resolveDataPath },
    { "airportinfo", f_airportinfo },
  { "finddata", f_findDataDir },
    { 0, 0 }
  { "parsexml", f_parsexml },
  };
  { "parse_markdown", f_parse_markdown },
  { "md5", f_md5 },
  { "systime", f_systime },
  { 0, 0 }
};
</syntaxhighlight>
</syntaxhighlight>


5

edits

Navigation menu