* James Turner -- Tuesday 18 April 2006 10:46:
> [...] I need to think a bit more about how to extend the notion of groups
> to enable the things I mentioned in my original email (particularly the  
> ability to run Nasal scripts when different run-levels are started). [...]

As you know, the reason for Nasal being the last of the subsystems is that
it processes the files in $FG_ROOT/Nasal/ on initialization. And the idea
was that these scripts should find all subsystems initialized, so that they
can access some generated properties immediately (such as values added by
the envirnoment subsystem etc.). But some of the subsystems do in turn need
Nasal, which is why the postinit() method was introduced. To make things
worse, some of the startup Nasal scripts need each other. Most require
props.nas, for example. And this is why we need the "settimer(INIT, 0)"
delay.

I don't want to interfere with Andy's business, but he had thought about
automatic dependency checking/resolution of Nasal modules, so that, for
example, screen.nas could say 'require("props")', or something. If this were
present, then it could be extended to allow subsystem dependencies, too.

Alternatively, the subsystems could set a 'signal'. This is a trivial but
useful feature that I introduced not too long ago. Some events in fgfs simply
set a bool property in /sim/signals/, for example: /sim/signals/reinit on
reinitialization (Shift-Esc), or /sim/signals/exit on exit. That way
Nasal code can attach listeners to the signal, and have code triggered
by the event. A wrapper around that could look like this:

  on_subsystem_init = func(which, what) {
      setlistener("/sim/signals/subsystem/" ~ which, what);
  }

Then Nasal files that *really* want to wait for a subsystem, could say

  on_subsystem_init("environment", print_temperature);

Or one could make the boolean become true on subsystem initialization, and
false on subsystem destruction (useful for changing aircraft during an fgfs
session, etc.)

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