Plugin Handout

advertisement
The five required functions in a plugin:






XPluginStart – runs once, during X-Plane startup
XPluginStop – runs once, during X-Plane shutdown
XPluginEnable – redundant with XPluginStart
XPluginDisable – redundant with XPluginStop
XPluginReceiveMessage – Allows handling of messages from X-Plane or other plugins
XPluginStart
XPluginStart
def XPluginStart(self):
self.Name = “SomeName”
self.Sig = “CalPoly.FlightSim.Name”
self.Desc = “A short description”
# any other code to run on startup
PLUGIN_API int XPluginStart( char* outName,
char* outSig,
char* outDesc )
{
strcpy(outName, “SomeName”);
strcpy(outSig, “CalPoly.FlightSim.Name”);
strcpy(outDesc, “A short description”);
return self.Name, self.Sig, self.Desc
// any other code to run on startup
}
XPluginStop
def XPluginStop(self):
# any code to run on shutdown
# if there’s nothing here, you need a pass
# statement
pass
PLUGIN_API void XPluginStop()
{
// any code to run on shutdown
}
XPluginEnable, XPluginDisable
def XPluginEnable(self):
# any code to run when plugin is enabled
return 1
PLUGIN_API int XPluginEnable()
{
// any code to run when plugin is enabled
return 1;
}
def XPluginDisable(self):
# any code to run when plugin is disabled
# need a pass statement if empty
pass
PLUGIN_API void XPluginDisable()
{
// any code to run when plugin is disabled
}
XPluginReceiveMessage
def XPluginReceiveMessage( self,
inSender,
inMessage,
inParam )
# any code to handle plugin messages
# need a pass statement if empty
pass
PLUGIN_API void XPluginReceiveMessage(
XPLMPluginID inSender,
long
inMessage,
void*
inParam
)
{
// any code to handle plugin messages
}
Download