266
edits
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/ | * 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 | 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 | ||
* | * get the list of registered add-ons | ||
* load the addon-main.nas file of each add-on into namespace __addon[ADDON_ID]__ | |||
* | * call function main() from every such addon-main.nas with the add-on ghost as argument. | ||
* | |||
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> |
edits