On Thu, Jan 19, 2006 at 09:36:38PM +0000, AJ MacLeod wrote: > I am in need of some sage advice on property listeners. Could someone > enlighten me on the easiest way to convert the following type of function to > respond to, for example, the "sim/model/lightning/controls/flight/ap_pitch" > property?
If you want to listen to a property that changes several times per frame, then a simple settimer loop is the best thing to do. A timer value of 0 makes sure that the function is run once per frame. Otherwise (and if the property is not tied!) a listener function is the way to go. > # Pitch Hold / Off > autpilot_pitch = func { > > aircraftpitch = getprop('orientation/pitch-deg[0]'); > > on = arg[0]; > > if ( on != '1' ) { > setprop("autopilot/locks/altitude[0]", ""); > setprop("sim/model/lightning/controls/flight/ap_pitch", "0"); > setprop("autopilot/gui/alt-active[0]", "false"); > } > else { > setprop("sim/model/lightning/controls/flight/ap_pitch", "1"); > setprop("autopilot/settings/target-pitch-deg[0]", aircraftpitch); > setprop("autopilot/locks/altitude[0]", "pitch-hold"); > } > } # end function autopilot_pitch = func { new_ap_pitch = cmdarg().getValue(); ... } setlistener("sim/model/lightning/controls/flight/ap_pitch", autopilot_pitch); m. ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel