* Justin Smithies -- Monday 06 March 2006 13:40:
> But just to get me going could you write it out as if it 
> was doing the following in script form.
> That should help me heaps to understand this and keep me busy too ;)
> 
> Say i wanted to monitor the /engines/engine[0]/cutoff property.
> If it ever changed to true i would like to erm just for the sake of it say 
> turn /engines/engine[0]/reverse to true.

Assuming that you only want changes from "false" to "true",
then you'd write something like that:

  last_cutoff = 0;
  setlistener("/engines/engine[0]/cutoff", func {
          var new_cutoff = cmdarg().getBoolValue();
          if (new_cutoff and !last_cutoff) {
                  setprop("/engines/engine[0]/reverse", 1);
          }
          last_cutoff = new_cutoff;
  }, 1);


... because the function isn't really only called on property
changes, but rather whenever the property is written to. Even
if it's the same value that's written. The 1 in the last line
makes sure that an initially "true" cutoff also sets the
reverser, which you may or may not want.

m.


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to