Board index FlightGear Development Nasal

Binding Nasal to a property

Nasal is the scripting language of FlightGear.

Binding Nasal to a property

Postby Xmaksasx » Tue Jul 30, 2019 7:03 pm

Hi everyone
please tell me can I run the Nasal script using a property?

for example:
I have the autostart property modifiable by UDP, if the property has 1 then run the Autostart script.
Xmaksasx
 
Posts: 6
Joined: Wed Jun 12, 2019 8:18 am

Re: Binding Nasal to a property

Postby wlbragg » Tue Jul 30, 2019 8:19 pm

You can use a listener...

Code: Select all
setlistener("/incoming/property/from/UDP/event", func (node) {
    if (node.getValue()) {
       nasal_autostart_command();
    }
}, 1, 0);


Or if you have a master loop running all the time you could poll the property yourself and do the same...

Code: Select all
var global_system_loop = func {
    if (getprop("/incoming/property/from/UDP/event") ==1)
         nasal_autostart_command();
    }
}
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 4991
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Binding Nasal to a property

Postby Xmaksasx » Wed Jul 31, 2019 7:44 am

Thank you very much, it works so great! :)
Xmaksasx
 
Posts: 6
Joined: Wed Jun 12, 2019 8:18 am


Return to Nasal

Who is online

Users browsing this forum: No registered users and 1 guest