* Curtis Olson -- 11/5/2008 3:20 PM: > What is the proper mechanism for calling nasal initialization code in an > aircraft specific nasal file.
settimer() and setlistener("sim/signals/fdm-initialized"), or just put it on the top level, where it's run late enough for most purposes. > I see that core nasal code sets a listener on > /sim/signals/nasal-dir-initialized however, I don't really care when the > nasal-dir is initialized for aircraft specific code since it doesn't live in > the main nasal directory. Exactly. So don't use it. (And it wouldn't work, anyway, as the signal is raised before aircraft code is even executed. So the listener would never get triggered.) > Would it be nitpicky of me to ask what it means > to initialize a directory? If you have a better suggestion, I have no problem changing it. > So is there a "proper" way to do this. I understand the old "set timer" > mechanism is discouraged. It shouldn't be used by files in $FG_ROOT/Nasal/, unless there's a concrete reason for it. The order is this: (a) nasal files in $FG_ROOT/Nasal/ loaded and executed in file-system ("random") order (b) sim/signals/nasal-dir-initialized signal raised, so that modules can now safely access definitions (functions, classes) from other modules as defined in (a). This also triggers the following (at a "random" moment): (c) files in $FG_HOME/Nasal/ loaded and executed in alphabetical order (that is, after sorting the file names with Nasal's sort()+cmp()) (d) scripts/code specified under property /nasal/ loaded and executed in the order of the respective nodes (e) settimer(..., 0) callbacks called for the first time ("INIT") (f) sim/signals/fdm-initialized signal raised (and its callback functions executed) Aircraft code joins the party at (d). The reason why "core" modules shouldn't use settimer() for initialization is, that steps (c) and (d) can then not safely access code initialized by that. Because setlistener() is a wrapper for the built-in function _setlistener(), it may also not be used in core files on the top level. m. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel