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 8: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 9:18 am

Re: Binding Nasal to a property

Postby wlbragg » Tue Jul 30, 2019 9: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 and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7586
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Binding Nasal to a property

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

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


Return to Nasal

Who is online

Users browsing this forum: No registered users and 6 guests