To a limited extent, X-Plane also appears as another plugin. The plugin will receive messages from X-Plane as if it was a plugin. The most common usage of the plugin management APIs is to receive notifications from X-Plane.
If we only need to receive notifications of simulator events from X-Plane, simply read the sections on interplugin messaging and receiving messages from X-Plane. Receiving notifications from X-Plane is very easy to do. The rest of the APIs discussed here are for advanced users.
The infrastructure to enable and disable plugins is entirely public and available via plugin management. The standard user interface to manage plugins is actually in itself provided by a plugin, and it is possible to rewrite, remove, or replace this functionality.
The value XPLM_NO_PLUGIN_ID (-1) is reserved to indicate that the lack of a plug-in or all plug-ins depending on the API. In some APIs this value is not allowed. The value XPLM_PLUGIN_XPLANE is used to indicate X-Plane in contexts where the simulator may be treated like a plug-in.
There are a number of ways to get a plug-ins ID:
Messages may either be broadcast to all plugins or to one specific plugin. Plugins may ignore messages they receive. Disabled plugins do not receive messages.
X-Plane will also send messages to plugins. All of X-Plane's messages are broadcast to all plugins. See the separate messaging documentation for information on the messages that X-Plane sends to plugins.
Plugin messages are always sent serially; when we send a message to a plugin, the plugin stops until the receiving plugin fully handles the message. The simulator does not run during any of this time. For this reason, make sure the messaging handling code is efficient.
< LISTING - Find a plugin by signature and sending a message to it >
We can also locate all plugins. This function dumps information about all plugins to a file:
< LISTING - Iterating across all plugins and dumping their stats >
A plugin can also get information about itself. This listing finds the location of our DLL on disk by getting our ID and getting info about us.
< LISTING - A plugin finding itself and getting its file location >
< LISTING - routine that prints info to disk from above >
< LISTING - disabling all other plugins >
< LISTING - A plugin sendind a msg to itself, one other plugin, and then all plugins>
A plugin receives messages from other plugins via its XPluginReceiveMessage callback. This callback receives messages from another plugin to add a waypoint to a flight plan.
< LISTING - A plugin that receives waypoint data and adds it to a flight-plan>
We receive messages from X-Plane via the XPluginReceiveMessage callback. This callback responds to the user picking a new plane.
< LISTING - A plugin receives a plane load message from X-Plane>
XPLMPlugin.hAlso, see chapter 1, Developing Plugins, and the separate comprehensive list of X-Plane messages.