Addon: Difference between revisions

Jump to navigation Jump to search
97 bytes added ,  12 July 2020
→‎Creating an addon: Some clarifications and corrections. In contrast to the initial forum announcement the skeleton addon and source files indicates that some file names should be prefixed with "addon-".
m (Johan G moved page Addons to Addon: Title in singular form)
(→‎Creating an addon: Some clarifications and corrections. In contrast to the initial forum announcement the skeleton addon and source files indicates that some file names should be prefixed with "addon-".)
Line 25: Line 25:
== Creating an addon ==
== Creating an addon ==
There is a very simple Skeleton addon available in FGAddon to be used as a template.<ref name="Forum_announcement"/> See {{fgaddon source|path=Addons/Skeleton}}.
There is a very simple Skeleton addon available in FGAddon to be used as a template.<ref name="Forum_announcement"/> See {{fgaddon source|path=Addons/Skeleton}}.
A leading slash (<code>/</code>) in this section indicates the base directory of the directory structure of the addon.


=== Minimum configuration ===
=== Minimum configuration ===
An addon may be installed in a directory anywhere on your hard disk and need at least two files:<ref name="Forum_announcement"/>
An addon may be installed in a directory anywhere on your hard disk and need at least two files:


* <code>/config.xml</code> - A standard [[PropertyList XML files|PropertyList XML file]] to be used to populate or modify the [[property tree]]. (Same as to be used in <code>--config=foo.xml</code>)
* <code>/addon-config.xml</code> - A standard [[PropertyList XML files|PropertyList XML file]] to be used to populate or modify the [[property tree]]. (Same as to be used in <code>--config=foo.xml</code>)
* <code>/main.nas</code> - The Nasal hook for the logic. This file needs a function called <code>main()</code> which will be called from the global addon initializer (<code>addons.nas</code>)
* <code>/addon-main.nas</code> - The Nasal hook for the logic. This file needs a function called <code>main()</code> which will be called from the global addon initializer (<code>addons.nas</code>)


=== Additional common files ===
=== Additional common files ===
Line 38: Line 40:


=== Good to know ===
=== Good to know ===
The new addon "API" lets you add a <code>addon-config.xml</code> to override the settings in <code>defaults.xml</code> and other files.
The new addon mechanism lets you add a <code>addon-config.xml</code> to override the settings in <code>defaults.xml</code> and other files.


That easily allows to
That will allow an addon to
*  Override key bindings (as in the spoken ATC addon)
*  Override key bindings (as in the spoken ATC addon)
*  Add or override autopilots and property rules
*  Add or override autopilots and property rules
And of course introduce XML statemachines
Introduce XML state machines


Unless your really want to add/change/remove those at runtime, this should cater for most use cases.<ref>{{cite web
Unless your really want to add/change/remove those at runtime, this should cater for most use cases.<ref>{{cite web

Navigation menu