Board index FlightGear Development Nasal

When is a Nasal script executed, when is it not ?  Topic is solved

Nasal is the scripting language of FlightGear.

When is a Nasal script executed, when is it not ?

Postby mhab » Fri Nov 18, 2016 1:09 am

Hello

I have dug through all I could find about Nasal docu in FG wiki and still have not found a clear answer about when a Nasal script embedded in an XML <Propertylist><nasal>..</nasal></Propertylist> file is executed.

I put the following into a XML file I include from the aircraft-set.xml file and it seems it is not executed.

The Head part of the aircraft-set.xml file
Code: Select all
<PropertyList include="Models/SearchLight/searchlight_config.xml">

and the searchlight_config.xml file
Code: Select all
<PropertyList>
  <nasal>
    <slight>
      <file>Models/SearchLight/searchlight.nas</file>
    </slight>
    <script>
      <!-- init searchlight props with delay
           otherwise Nasal error is raised   -->
      setlistener("/sim/signals/fdm-initialized", func {
        settimer(func {
          slight.slight_init();
          print("searchlights initialized ...");
        }, 1);
      });
    </script>
  </nasal>

What is wrong with this approach ?
I used it in an almost identical way, but it doesn't seem to work here ...
Any other way to run a script from the included file ?

Thanks
Mike-DE
mhab
 
Posts: 418
Joined: Thu Apr 18, 2013 11:59 pm
Callsign: D-MIKE
Version: 2020.3.4
OS: Win10

Re: When is a Nasal script executed, when is it not ?  

Postby mhab » Fri Nov 18, 2016 1:21 am

Hello
Posting here sure is a funny way to find the solution finally ;-)
Well the problem was small and hidden but it works in this way (<script></script> shifted one level):
Code: Select all
<PropertyList>
  <nasal>
    <slight>
      <file>Models/SearchLight/searchlight.nas</file>
      <script>
        <!-- init searchlight props with delay
             otherwise Nasal error is raised   -->
        setlistener("/sim/signals/fdm-initialized", func {
          settimer(func {
            slight.slight_init();
            print("searchlights initialized ...");
          }, 1);
        });
      </script>
    </slight>
  </nasal>

Thanks
Mike-DE
mhab
 
Posts: 418
Joined: Thu Apr 18, 2013 11:59 pm
Callsign: D-MIKE
Version: 2020.3.4
OS: Win10

Re: When is a Nasal script executed, when is it not ?

Postby Johan G » Fri Nov 18, 2016 8:58 pm

Trying to hunt down issues like that could make anyone pull his hair...
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit


Return to Nasal

Who is online

Users browsing this forum: No registered users and 3 guests