* Syd&Sandy -- Thursday 15 November 2007:
> but does the "lookat" now look at anything other than your
> own aircraft ? 

Huh? It has always looked at the selected target. By default it's your
own aircraft, but you can switch through all carriers, tankers,
trafficmanager aircraft, and multiplayer aircraft with the q/Q key.



> And is it safe to convert my setlisteners to the new format ?

Yes. There's only the (old) special case in $FG_ROOT/Nasal/*.nas
files, where you can't use setlistener() at the top-level, as it
depends on stuff in props.nas, which isn't guaranteed to be
initialized early enough. But that's not a problem in aircraft
Nasal files.



> Actually , I always thought the code was executed only when the
> listened to property was modified , which explaines some of my
> questionable routines :) 

But it has always been said that this was not the case. Now
it's optional.

  setlistener(<prop>, <func> [, <init=0> [, <runtime=1>]]);

  init = 0     ... func not run initially  (default)
         1     ... func run initially

  runtime = 0  ... func only called on changes
            1  ... func called on every write access (default!)
            2  ... like 1, but also when children values are written
                   to, or children are added or removed

  1 is default for historical reasons. 0 would be a better default.


A listener callback function can still use cmdarg() like before, but
it's now recommended to use regular function arguments. Up to four
are provided, but you need only to define the ones that you need.
The four args are:

  func(<changed-node>, <listened-to-node>, <event>, <is-parent-event>)

In most cases you need one or none of the arguments:

  setlistener("/foo", func { print("hello") });
  setlistener("/foo", func(a) { print("foo=", a.getValue()) });

The additional args are for runtime=2 ("children") mode, while
in the other modes <changed-node> and <listened-to-node> are
identical and <event> is always 0 and <is-parent-event> always 1.

In runtime=2 mode the <changed-node> can be any of the <listened-to-node>'s
children. <event> is -1 when a child is removed, 1 when it was added,
and 0 when a value was changed. <is-parent-event> is 1 when both nodes
are identical, and 0 otherwise. (That's only to save (a lot of) CPU
cycles, as comparing the nodes in Nasal space is rather expensive.)

m.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to