XML: Macros - Universal Timer

From FSDeveloper Wiki
Revision as of 08:09, 19 August 2014 by N4gix (talk | contribs) (Created page with "{{Infobox-Applicable-FSVersion | P3D = true | FSXA = true | FSX = true | FS2004 = true | FS2002 = false | FS2000 = unknown | FS98 = unknown }} ''' Universal Timer Macros ''' ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Universal Timer Macros

Making elapsed time based on gauge update cycle is simple to code and easy to understand.

Courtesy of Tom Aguilo (taguilo) in post: http://www.fsdeveloper.com/forum/threads/adding-a-timer.431123/#post-681198

A group of macros, but with an universal score could be :

<Macro Name="GetElapsed">
  (P:Absolute time,@2) (L:@1,@2) - abs
</Macro>
<Macro Name="SetElapsed">
  (P:Absolute time,@2) (>L:@1,@2)
</Macro>

And then using:

@SetElapsed(name_of_var,unit)
@GetElapsed(name_of_var,unit)

For example (pseudocode):

<Update>
   (A:TURB ENG ITT:1, celsius) 907 >
   if{  @SetElapsed(MyTimer,minutes)  }
   ...
   ...
   @GetElapsed(MyTimer,minutes) 5 >
   if{ do something }
   ...
</Update>

Both macros can be copied and pasted on every gauge so to have elapsed timers available for the entire code.