ferram4 / Ferram-Aerospace-Research

Aerodynamics model for Kerbal Space Program
Other
239 stars 131 forks source link

Expose flap setting and controls in FARAPI? #96

Closed MOARdV closed 9 years ago

MOARdV commented 9 years ago

I have a feature request for RasterPropMonitor to extend FAR support by reporting the current state of the flaps and spoilers (as numeric values, ranging 0-3 for flaps, and 0-1 for spoilers, presumably). In addition to reading the current setting, I'd like to be able to notify FAR that the user wants to change settings (deploy / retract spoilers, and raise/lower flaps - either by a step, or by directly setting the value, like SetFlaps(2)).

If this is something I can do from another plugin without changes to FAR or FARAPI, please let me know where I should be looking in the FAR source to find the functions I need to use; otherwise, please consider exposing this functionality through FARAPI.

ferram4 commented 9 years ago

Hmm, yeah, this will require FARAPI changes. Shouldn't be that difficult to do, so I'll see about adding it.

ferram4 commented 9 years ago

Flap and spoiler values can now be read through FARAPI, and can be set; spoilers directly through FARAPI, flaps can be incremented and decremented. Dev build should work fine, just keep in mind that it is now built against ModularFlightIntegrator 1.1, and it will not work with 1.0.

MOARdV commented 9 years ago

Thank you. I'll give it a look here and get it incorporated.

MOARdV commented 9 years ago

I tried a locally-built FAR based on a snapshot from today, and MFI 1.1. FARAPI.VesselSpoilerSetting appears to work as expected (toggles state when I tap the 'B' key for brakes. However, FARAPI.VesselFlapSetting only returns 2.

It may be that, since I'm not a spaceplane guy, I did something wrong - I did not design an aircraft with intent for it to fly. All I did was use a Jumbo64 fuel tank as a fuselage, attach big wings, and add a couple of control surface. One was set to work as flaps, the other as spoilers. I was able to change the flap settings from outside the craft, and the context menu showed the expected buttons for increase/decrease flaps, and it reported the flaps at the expected value. However, FARAPI.VesselFlapSetting still insisted the flaps were at 2.

I have not tried the incrase/decrease flaps or the set spoilers methods yet.

If you have a suggestion for what I might try differently, I'd appreciate it.

ferram4 commented 9 years ago

Try the latest build, that should work now.

Only issue I can think of is that asking for a single flap or spoiler setting for a vehicle might not return the exact expected value; if you use the right-click menu to activate spoilers or set flap deflection it won't set for the entire vehicle and the value returned will be the first flap or spoiler it finds.

MOARdV commented 9 years ago

Okay, that change worked for me, and I've confirmed that the FARAPI methods to set spoilers and adjust flaps work. Thank you once again.