Addon: Difference between revisions

Jump to navigation Jump to search
83 bytes removed ,  4 December 2018
no edit summary
No edit summary
Line 49: Line 49:




The new addon "API" lets you add a config.xml to override the settings in defaults.xml.
The new addon "API" lets you add a addon-config.xml to override the settings in defaults.xml.


That easily allows to
That easily allows to
Line 98: Line 98:


We now have a simple API to add addons to FlightGear without the need to mess around with FGData/Nasal or FGHome/Nasal directories. FlightGear now accepts the command line switch --addon=/path/to/some/addon (note: command line switch is just that: a command line switch - not an option to be entered into the launcher). fgfs (through options.cxx) takes care of  
We now have a simple API to add addons to FlightGear without the need to mess around with FGData/Nasal or FGHome/Nasal directories. FlightGear now accepts the command line switch --addon=/path/to/some/addon (note: command line switch is just that: a command line switch - not an option to be entered into the launcher). fgfs (through options.cxx) takes care of  
* creating a property under /addons/addon[n]/path=/path/to/some/addon
* creating a property under /addons/by-id/org.flightgear.addons.<addonName>/
* adding /path/to/some/addon/config.xml as a config file (same as --config=/path/to/some/addon/config.xml)  
* adding /path/to/some/addon/addon-config.xml as a config file (same as --config=/path/to/some/addon/addon-config.xml)  
* adding /path/to/some/addon to the list of allowed directories (same as --fg-aircraft=/path/to/some/addon)  
* adding /path/to/some/addon to the list of allowed directories (same as --fg-aircraft=/path/to/some/addon)  


The addon may be installed anywhere on your hard disk and it needs at least two files:  
The addon may be installed anywhere on your hard disk and it needs at least two files:  
* config.xml - a standard PropertyList to be used to populate or modify the property tree. (Same as to be used in --config=foo.xml)  
* addon-config.xml - a standard PropertyList to be used to populate or modify the property tree. (Same as to be used in --config=foo.xml)  
* main.nas - the Nasal hook for the logic. This file needs a function called main() which will be called from the global addon initialier (FGData/addons.nas)  
* addon-main.nas - the Nasal hook for the logic. This file needs a function called main() which will be called from the global addon initialier (FGData/addons.nas)  


It is pretty simple but does it's job nicely with our two addons we currently have in FGAddon (ATCChatter and SpokenATC). There is a /very/ simple Skeleton addon available to be used as a boilerplate here: https://sourceforge.net/p/flightgear/fgaddon/HEAD/tree/trunk/Addons/Skeleton/ As always: feedback is much appreciated. <ref>{{cite web
It is pretty simple but does it's job nicely. There is a /very/ simple Skeleton addon available to be used as a boilerplate here: https://sourceforge.net/p/flightgear/fgaddon/HEAD/tree/trunk/Addons/Skeleton/ As always: feedback is much appreciated. <ref>{{cite web
   |url    =  https://sourceforge.net/p/flightgear/mailman/message/35951307/  
   |url    =  https://sourceforge.net/p/flightgear/mailman/message/35951307/  
   |title  =  <nowiki> [Flightgear-devel] Simple API for creating FlightGear addons/plugins </nowiki>  
   |title  =  <nowiki> [Flightgear-devel] Simple API for creating FlightGear addons/plugins </nowiki>  
Line 148: Line 148:
For the time being, the addon.nas module will:
For the time being, the addon.nas module will:
* initialize addons configured with --addon=foobar command line switch
* initialize addons configured with --addon=foobar command line switch
* loop over /addons/addon[n] nodes
* get the list of registered add-ons
get root path in /addons/addon[n]/path property (set by options.cxx from --addon=/foo/bar)
* load the addon-main.nas file of each add-on into namespace __addon[ADDON_ID]__
* load main.nas therein into namespace __addon[n]__
* call function main() from every such addon-main.nas with the add-on ghost as argument.
* call function main() from that main.nas with addon-path as arg
 


It depend on a change to options.cxx to accept an optional --addon argument <ref>https://sourceforge.net/p/flightgear/flightgear/ci/f6698a0b1f9e8c0791314aa09cbe1625927ef3ff/</ref>
It depend on a change to options.cxx to accept an optional --addon argument <ref>https://sourceforge.net/p/flightgear/flightgear/ci/f6698a0b1f9e8c0791314aa09cbe1625927ef3ff/</ref>
266

edits

Navigation menu