tkyler Posted April 23, 2010 Report Posted April 23, 2010 This is a note for developers. X-Plane handles interior lighting with two datarefs:sim/cockpit2/switches/instrument_brightness_ratio[n]sim/cockpit2/switches/panel_brightness_ratio[n]These datarefs are arrays that hold up to 16 values (indexes 0-15). The range of value is between zero and one. The default values found in these array variables when loading an aircraft is 0.75 for all indicies.When using a plug-in to manage these datarefs, it is important that you reset all the array values of these datarefs to 0.75 when unloading the aircraft, otherwise, the next aircraft loaded can load with the previous lighting settings. If the previous aircraft had some lighting set to zero, then the next aircraft loaded can have dark instrumentation and look like the unit is off when it is not.Here's the code I use to set lighting upon exiting the aircraft:void Controls_reset_lighting(void){ float i[16] = {0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75,}; XPLMSetDatavf(xp_DR_inst_brt, i, 0, 16); XPLMSetDatai(xp_DR_nav2_power, 1); XPLMSetDatai(xp_DR_gps_fuse, 1);} Quote
JGregory Posted April 23, 2010 Report Posted April 23, 2010 Tom, Would it also be a good idea to set/reset all the values of the same Datarefs on "startup" of the plugin for "your" aircraft, thus insuring that no matter what any other aircraft plugin does "yours" will always work as designed?Jim Quote
tkyler Posted April 24, 2010 Author Report Posted April 24, 2010 Definitely, and I do that on the Falco...at least on a lot of datarefs, I could probably stand to do it on a few more, but it's the "cleanup" on exit that is a courtesy to the end user so they don't have problems with subsequent aircraft that I was wanting to convey.Something about setting datarefs by plugin is carrying over to the following loaded aircraft. I'll ask about this one to laminar. Quote
MatthewS Posted April 24, 2010 Report Posted April 24, 2010 When using a plug-in to manage these datarefs, it is important that you reset all the array values of these datarefs to 0.75 when unloading the aircraft, otherwise, the next aircraft loaded can load with the previous lighting settings. If the previous aircraft had some lighting set to zero, then the next aircraft loaded can have dark instrumentation and look like the unit is off when it is not.Maybe this should be logged as a bug so Austin/Ben can fix? Seems to me that XPlane should be resetting all datarefs to a default state upon loading an aircraft. Quote
Ben Russell Posted April 24, 2010 Report Posted April 24, 2010 there's 4,000+ datarefs to audit. we're in a growing phase for x-plane where it is moving into a phase where plugins almost didnt exist to where they're basically required to do anything interesting.quirks like this are to be expected, its good to raise them, but its best to do it in a way that doesnt point any fingers to angrily. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.