Board index FlightGear Development

Livery XML file: how to call a nasal script

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

Livery XML file: how to call a nasal script

Postby mhab » Sun Oct 20, 2013 12:37 am

Hello

It may be a simple problem, hopefully.

Is it possible to call a nasal script from a Livery specific XML file, so it is executed whenever that livery is loaded ?
I know how to call a script from the "<aircraft>-set.xml" file, but it doesn't seem to work in a livery specific XML file ...

Thanks
Mike-DE
mhab
 
Posts: 410
Joined: Thu Apr 18, 2013 10:59 pm
Callsign: D-MIKE
Version: 2019.1.1
OS: Win10

Re: Livery XML file: how to call a nasal script

Postby Hooray » Sun Oct 20, 2013 9:27 am

just make it part of the main aircraft-set.xml file and register a listener to get notified once the livery changes and you can run any Nasal code
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11376
Joined: Tue Mar 25, 2008 8:40 am

Re: Livery XML file: how to call a nasal script

Postby Philosopher » Sun Oct 20, 2013 5:42 pm

Or have a /sim/model/livery/script node (is that the right path?) that has a listener that runs it when changed. That way livery files have the code embedded in them. Example Nasal code:

Code: Select all
globals["__livery"] = {}; # namespace for livery scripts

setlistener(props.globals.initNode("sim/model/livery/script", "", "STRING"), func(n) {
    call(bind(compile(n.getValue(), "/sim/model/livery/script"), globals), nil, nil, globals["__livery"]);
});
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5


Return to Development

Who is online

Users browsing this forum: No registered users and 2 guests