Nasal library: Difference between revisions

Jump to navigation Jump to search
798 bytes removed ,  12 December 2016
→‎maketimer(): Doc simulatedTime member
(→‎maketimer(): Doc simulatedTime member)
Line 1,739: Line 1,739:


=== maketimer() ===
=== maketimer() ===
{{Note|
As part of investigating the possibility of running a trimming time period, James noticed that our current Nasal timers don’t actually expose the ‘sim vs realtime’ option from the Event-manager, so he's pushed a change to fix this. It’s via a boolean attribute ‘simulatedTime’, defaults to false for backwards compatibility. The ‘settimer’ approach does support this flag since ‘forever’ but of course settimer should eventually be replaced with timer-objects to reduce GC thrash in Nasal. The attribute can’t be changed while the timer is running, BTW. But you can stop the timer, change the value and start it again. Probably, > 50% of Nasal timers should be using simulated time, so pause and sim-speed-up work automatically<ref>{{cite web
  |url    =  https://sourceforge.net/p/flightgear/mailman/message/35545028/
  |title  =  <nowiki> [Flightgear-devel] Nasal timers using sim-dt </nowiki>
  |author =  <nowiki> James Turner </nowiki>
  |date  =  Dec 11th, 2016
  |added  =  Dec 11th, 2016
  |script_version = 0.40
  }}</ref>
}}
{{Nasal doc
{{Nasal doc
|syntax = maketimer(interval[, self], function);
|syntax = maketimer(interval[, self], function);
Line 1,762: Line 1,750:
* '''singleShot''': Bool showing whether the timer is only to be run once, or continuously until told to stop. Can be both set and read from (see examples).
* '''singleShot''': Bool showing whether the timer is only to be run once, or continuously until told to stop. Can be both set and read from (see examples).
* '''isRunning''': Read-only bool telling whether the timer is currently running.
* '''isRunning''': Read-only bool telling whether the timer is currently running.
* '''simulatedTime''': (FG 2017.1+; {{flightgear commit|0af316|t=commit}}) Bool telling whether the timer is using simulated time (which accounts for pause, etc.). Defaults to false (use real time). Can be both read and set. This cannot be changed while the timer is running.
Unlike {{func link|settimer()}}, which it replaces, <code>maketimer()</code> provides more control over the timer. In addition, it can help reduce memory usage.
Unlike {{func link|settimer()}}, which it replaces, <code>maketimer()</code> provides more control over the timer. In addition, it can help reduce memory usage.
|param1 = interval
|param1 = interval

Navigation menu