Board index FlightGear Development Nasal

Beginners reference of Nasal

Nasal is the scripting language of FlightGear.

Beginners reference of Nasal

Postby mmgfg2 » Wed Sep 30, 2015 3:51 pm

I tried to summary rules of FG to use nasal script in http://wiki.flightgear.org/Creating_new_Nasal_scripts (and so on), but

1.
..."sub modules" provide support for on-demand loading
...All sub modules are automatically loaded AFTER $FG_ROOT/Nasal has been processed
So on-demand or automatically?

Folks waste hours trying to guess the real nasal behaviour after the manuals.
As i guess, we need switch "enabled" to "true" to load them on demand.

2.
... Submodules are loaded _after_ the main fgdata/Nasal scripts,
so they can rely on all fgdata/Nasal content to be already present.

so why _setlistener instead of setlistener is used in example
Code: Select all
_setlistener("/nasal/my_module/loaded", init);
is it not mandatory uses _setlistener here in comparison with
Code: Select all
_setlistener("/sim/signals/nasal-dir-initialized", mycode);


3.
there are some tricks in xml to express what you want, for example

the following seq gives us module test1 listed in /nasal/test1/file[0-2] property tree
with only one property /nasal/test1/loaded
Code: Select all
<nasal n="0">
       <test1 n="0"><file n="0">Aircraft/test/Nasal/test/test1_1.nas</file></test1>
       <test1 n="0"><file n="1">Aircraft/test/Nasal/test/test1_2.nas</file></test1>
</nasal>
<nasal n="0">
       <test1 n="0"><file n="2">Aircraft/test/Nasal/test/test1_3.nas</file></test1>
</nasal>


the following seq gives us module test1 listed in /nasal/test1[0-2]/file property tree
with three separated property /nasal/test1[0-2]/loaded
Code: Select all
<nasal n="0">
       <test1 n="0"><file n="0">Aircraft/test/Nasal/test/test1_1.nas</file></test1>
       <test1 n="1"><file n="0">Aircraft/test/Nasal/test/test1_2.nas</file></test1>
</nasal>
<nasal n="0">
       <test1 n="2"><file n="0">Aircraft/test/Nasal/test/test1_3.nas</file></test1>
</nasal>
what way one sholud uses to user submodules
and is there a way (similar to submodules) to load all files of test1 and check they
was loaded by single /nasal/test1/loaded?

4.
Nasal code in model XML files

The code is load/unload as soon as tile loader decides to load/unload the model.
It is using two properies <load> and <unload>.

what models can be used with nasal embedded. I can't did it.
what is "the object has to be present at sim startup"?
what is namespace of the nasal code?
mmgfg2
 
Posts: 47
Joined: Wed Feb 25, 2015 12:51 pm

Re: Beginners reference of Nasal

Postby Necolatis » Sun Oct 16, 2016 12:00 pm

mmgfg2 wrote in Wed Sep 30, 2015 3:51 pm:what models can be used with nasal embedded. I can't did it.


It works for sure with the main model file. But notice that it only gets executed over MP. Meaning that when other planes load your model (if they have it installed) the embedded nasal will run local for them.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10


Return to Nasal

Who is online

Users browsing this forum: No registered users and 1 guest