Board index FlightGear Development Nasal

Nasal Sleep function?

Nasal is the scripting language of FlightGear.

Nasal Sleep function?

Postby D-ECHO » Sat Jul 09, 2016 7:39 am

Hi,
Is there a nasal function to do about the same as shell "sleep"? (Wait a specified time before continuing)
I've looked on the internet but I coudln't find anything....
Regards and thanks
D-ECHO
 
Posts: 2458
Joined: Sat May 09, 2015 1:31 pm
Pronouns: Bea (she/her)
Version: next

Re: Nasal Sleep function?

Postby PINTO » Sat Jul 09, 2016 7:54 am

You could use a timer! Other than that, not really.
Actively developing the MiG-21bis (github repo) (forum thread) (dev discord) (fg wiki)

http://opredflag.com is an active flightgear dogfighting community (using a system that isn’t bombable)
User avatar
PINTO
 
Posts: 966
Joined: Wed Oct 21, 2015 7:28 pm
Callsign: pinto
Version: stable
OS: Win10

Re: Nasal Sleep function?

Postby Thorsten » Sat Jul 09, 2016 8:58 am

It would seem to depend on the context, but in general I agree, this can be done with a timer.

(If the code to be executed runs in a loop, you can just change the loop timer, otherwise you have to factor out the code block to be delayed into a different function and call that block with a delay).
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Nasal Sleep function?

Postby PINTO » Sat Jul 09, 2016 9:03 am

Thorsten wrote in Sat Jul 09, 2016 8:58 am:If the code to be executed runs in a loop, you can just change the loop time

Variable loop timer is a great idea too.
Actively developing the MiG-21bis (github repo) (forum thread) (dev discord) (fg wiki)

http://opredflag.com is an active flightgear dogfighting community (using a system that isn’t bombable)
User avatar
PINTO
 
Posts: 966
Joined: Wed Oct 21, 2015 7:28 pm
Callsign: pinto
Version: stable
OS: Win10

Re: Nasal Sleep function?

Postby Hooray » Sat Jul 09, 2016 11:32 am

This is usually accomplished using "split-frame" loops - i.e. loops that do a little work and then register a timer to re-invoke themselves with the remaining work to be done - either way, you will usually want to use maketimer() instead of settimer().
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Nasal Sleep function?

Postby D-ECHO » Sat Jul 09, 2016 1:01 pm

Well, what I want to do is a function for tyresmoke, so that
1. rollspeed1 is /gear/gear/rollspeed-ms
2. wait a short time (0.05sec or so)
3. rollspeed2 is gear/gear/rollspeed-ms
4. compare both speeds
5. if it speeded up fast, produce tyresmoke
D-ECHO
 
Posts: 2458
Joined: Sat May 09, 2015 1:31 pm
Pronouns: Bea (she/her)
Version: next

Re: Nasal Sleep function?

Postby Hooray » Sat Jul 09, 2016 1:30 pm

You basically need a function that computes a delta between two values - so you can just register a maketimer() callback that looks at the previous value to compute the delta between the current value - previous value, you can use Nasal closures or an object to store those values, or even just global variables, and then set up the timer so that it calls itself after 50 ms: maketimer(delay, me, callback) - the me part can be used to pass an object that contains all previous state, i.e. even a vector with arbitrary many samples
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Nasal Sleep function?

Postby Thorsten » Sat Jul 09, 2016 2:05 pm

5. if it speeded up fast, produce tyresmoke


That's called the rollspeed acceleration, and you can simply do an derivative element in the FDM on the rollspeed properties to get the roll acceleration and probe that - I would not bother fiddling with Nasal for that, it's going to suck for the task because you buy into all sorts of framerate dependencies.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Nasal Sleep function?

Postby wlbragg » Sat Jul 09, 2016 4:29 pm

Out of curiosity, why not use the existing tyresmoke logic?
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: Nasal Sleep function?

Postby D-ECHO » Sat Jul 09, 2016 4:29 pm

There is an existing one?? :D
D-ECHO
 
Posts: 2458
Joined: Sat May 09, 2015 1:31 pm
Pronouns: Bea (she/her)
Version: next

Re: Nasal Sleep function?

Postby wlbragg » Sat Jul 09, 2016 4:31 pm

See c172p and I think I put it on the j3cub and the shuttle may even have an adaptation. If you need more specifics I can point you to the code once I find it, :lol:
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: Nasal Sleep function?

Postby wlbragg » Sat Jul 09, 2016 4:33 pm

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


Return to Nasal

Who is online

Users browsing this forum: No registered users and 3 guests