Board index FlightGear Development Nasal

location for user defined nasal listeners DC3 **solved**  Topic is solved

Nasal is the scripting language of FlightGear.

location for user defined nasal listeners DC3 **solved**

Postby Volador » Sat May 01, 2021 4:49 pm

I've got a working example here for the 747-8i-main.xml where was advised to add

<arduino-control>
<file>Aircraft/747-8i/Nasal/arduino-747.nas</file>
</arduino-control>

to the 747-8-main.xml between the <nasal></nasal> tags in order to 'call' my ardino-747.nas file which contains custom listeners for my interface (all working)

My question 1 is, how does FG use the <arduino-control> tag or is it just there to organise the code? Could it just go between the <747></747> tags?

Question 2 is, applying the same principal to the DC-3 JBsim, where would the <arduino-control> tags need to go as there seem to be so many .xml files dc-3-base.xml dc-3-jbsim.xml dc-3.xml. ...the reason I'm asking is because at the moment I have a hack pasted in to the dc3.nas:
Code: Select all
setprop("input/arduino/gear-down", 1);
setlistener("input/arduino/gear-down", func(v)
    {if (v.getBoolValue())
      {controls.gearDown(1);}
    else # if (v.getBoolValue() == 0 )
      {controls.gearDown(-1);}
    },1,0);

which listens to property to put the gear down but I'd like to tidy things up and have this code in a separate .nas file (just in case there are updates to the model and things get over-written).

I have some knowledge but this seems not as straight forward as the 747 example.
Last edited by Volador on Sun May 02, 2021 12:30 pm, edited 2 times in total.
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Re: where to put path to a user defined nasal script

Postby wlbragg » Sat May 01, 2021 5:17 pm

The arduino-control is not absolutely necessary, it's more an organizational asset.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7587
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: where to put path to a user defined nasal script

Postby Volador » Sat May 01, 2021 10:43 pm

Thanks Wlbragg :)
any clues on question 2 anyone?
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Re: where to put path to a user defined nasal script

Postby wlbragg » Sat May 01, 2021 11:06 pm

More than likely the nasal section is in that base.XML file. Open it up and just look in there and see if you have the nasal open and close tags in it.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7587
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: where to put path to a user defined nasal script  

Postby Volador » Sun May 02, 2021 11:13 am

Hi Wlbragg, yes, I found the nasal tags in the dc-3-base.xml and included a path to my arduino-DC3.nas file which is located in the Nasal folder for the DC3. The only thing is, not having that listener code in DC3.nas anymore (commented out for testing) the gear folds on startup again... is the order of these .nas paths a factor I wonder? My path to arduino-dc3.nas is currently at the end just before the closing </nasal> tag - will test it in a different position...

[edit] Success! my theory was right. By placing the arduino-DC3.nas file right at the top - I did try it just after the dc3.nas file but the gear folded again, at the top of the list (shown below) the gear stays where it should be - so I'd deducing the order is important in this case

Code: Select all
  <nasal>
    <doors>
      <file>Aircraft/Douglas-Dc3/Nasal/doors.nas</file>
    </doors>
    <para>
      <file>Aircraft/Douglas-Dc3/Nasal/paratroopers.nas</file>
    </para>
    <dc3>
      <!--The arduino.nas file path should be here in this aircraft -->
      <file>Aircraft/Douglas-Dc3/Nasal/arduino-DC3.nas</file>     
      <file>Aircraft/Douglas-Dc3/Nasal/dc3.nas</file>
      <file>Aircraft/Douglas-Dc3/Nasal/electrical.nas</file>
      <file>Aircraft/Douglas-Dc3/Nasal/interpolate.nas</file>
      <file>Aircraft/Douglas-Dc3/Nasal/liveries.nas</file>
      <file>Aircraft/Douglas-Dc3/Nasal/light.nas</file>
      <file>Aircraft/Douglas-Dc3/Nasal/immat.nas</file>
      <file>Aircraft/Douglas-Dc3/Nasal/hydraulic.nas</file>
      <file>Aircraft/Douglas-Dc3/Nasal/wipers.nas</file>
    </dc3>

    <chronograph>
      <file>Aircraft/Douglas-Dc3/Nasal/chronograph.nas</file>
    </chronograph>
    <VHF22>
     <file>Aircraft/Generic/DualControl/Instruments/VHF-22/ctl22.nas</file>
    </VHF22>

  </nasal>
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit


Return to Nasal

Who is online

Users browsing this forum: No registered users and 6 guests