xpnteam / xpnet

Develop X-Plane plugins in .NET.
MIT License
50 stars 15 forks source link

Commands and Messages #3

Closed sognatore99 closed 6 years ago

sognatore99 commented 6 years ago

So I have made a lot of progress but have a question on commands. I found out the hard way that commands can only be issued on the Flight Loop Hook. The problem is that the only way the flight hook is available is when you are starting a flight. I want to issue a command prior to that, on startup (when the display only shows Resume flight, new flight, load.., flight school, settings). Basically I want to load a situation without having the user intervention. BTW I am using sockets to communicate remotely with XPlane via your API. Any help on how to get access to XPlane at startup and to run a command on that thread would be helpful. Thanks in advance!

jaurenq commented 6 years ago

I don't know whether that's possible or not. I think that's going to be a question to take over to the "X-Plane Developers and Plugins" forum over on https://forums.x-plane.org/; it's more of a general "can this be done with the plugin API at all?" question than something specific to XPNet.

sognatore99 commented 6 years ago

Ok thanks. I have been searching a lot and it does not seem possible. I will pose a question there. Thanks for your help.

realsimgearinc commented 6 years ago

Are you able to provide a simple example of how the Commands are implemented?

jaurenq commented 6 years ago

There is an example in LoggerPlugin.cs. Get a reference to a command and invoke it like so:

var cmd = m_api.Commands.GetCommand("sim/autopilot/heading_up");
cmd.InvokeOnce();