Board index FlightGear Development Nasal

Repeat a nasal script?

Nasal is the scripting language of FlightGear.

Repeat a nasal script?

Postby 91cob » Wed Sep 26, 2018 3:24 pm

Hi, i've written a nasal script, and everything works well now, when its running in the Nasal-Console. But now I want to make it run in the background, as a loop. It has to be repeated over and over again while FG is running. How can I do this?
91cob
 
Posts: 1
Joined: Wed Sep 26, 2018 3:10 pm

Re: Repeat a nasal script?

Postby wlbragg » Wed Sep 26, 2018 4:33 pm

There are several ways you can do this. Search the wiki for "nasal loops" and it will give you a section on Listeners. That would be one method. The other is to call a function that loops itself with a timer. See "timers" in wiki.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
User avatar
wlbragg
 
Posts: 4303
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Debain/nVGT640

Re: Repeat a nasal script?

Postby Richard » Wed Sep 26, 2018 4:42 pm

Something like[1];

Code: Select all
var some_loop = func {

# your code goes here.
 
}

some_loop_Timer = maketimer(0.25, mt_loop_example);
some_loop_Timer.simulatedTime = 1; # use simulated time, as maketimer defaults to using wallclock time and continues during pause.
some_loop_Timer.start();


-------------
[1] http://wiki.flightgear.org/Nasal_Loops
Richard
 
Posts: 654
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10


Return to Nasal

Who is online

Users browsing this forum: No registered users and 0 guests