• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Timer code

Messages
10,163
Country
us-arizona
Hey all,

How would one write a timer for it to 'activate' every hour? I need it to trigger something every hour.

Many thanks,

Bill
LHC
 
Something like this should work??

(E:Zulu Time, hours) 1 % flr 0 ==

This should trigger on the hour (not tested though).

If you want more flexibility, then something like:

(E:Zulu Time, minutes) (L:Yourtime, minutes) ==

Set the L: variable to the minutes after the hour when you want the 1 hour timing to start. Then it will trigger every hour.

You may need to set a flag to prevent multiple triggering, if that's a problem.

Hope this helps,
 
Last edited:
Hi,
Tom beat me to it while i was struggling to get a code together in my Notepad2 editor...:)

But anyways, here's another approach which may be useful.
This one starts counting elapsed time from initialization of the gauge, not at every clockhour (such as 1 o'clock, 2 o'clock, which i suspect is what Tom's code does).
It does contain a flag to prevent multiple triggering (L:TimerSet, bool).

Code:
<Element>
         <Select>
         <Value>(L:TimerSet, bool) ! == if{
                  (P:Absolute Time, seconds) 3600 + (&gt;L:TimerNumber, seconds)  <!--set TimerNumber to a value of Absolute time + 1hr (3600 secs) -->
                    (L:TimerSet, bool) ! (&gt;L:TimerSet, bool)                   <!--make sure TimerNumber does not get set each gauge cycle--> 
                      0 (&gt;L:DoSomething, bool) }                               <!--make sure DoSomething equals 0, to prevent unwanted action-->
         </Value>
         </Select>
      </Element> 
      <Element>
         <Select>
         <Value>(P:Absolute Time, seconds) (L:TimerNumber, seconds) == if{ 
                  1 (&gt;L:DoSomething, bool)                     <!--when Absolute Time equals the previously set TimerNumber, 
                                                                      set the value of DoSomething,bool to 1 for further use in (other) gauge-->
                  (L:TimerSet, bool) ! (&gt;L:TimerSet, bool) }   <!--flips TimerSet so TimerNumber can be set to new value again-->                                
         </Value>
         </Select>
      </Element>

It triggers the custom Var L: DoSomething, bool which you can use to control your further action.

Hope this helps too! :D

grt
Willem
 
Last edited:
Back
Top