XML: Timer: Difference between revisions

From FSDeveloper Wiki
Jump to navigationJump to search
mNo edit summary
No edit summary
Line 32: Line 32:


[[Category:Aircraft Design]]
[[Category:Aircraft Design]]
[[Category:Panel & Gauge Design]]
[[Category:Panel and Gauge Design]]

Revision as of 13:49, 22 August 2011


XML: Timer

With this universal code it's very simple to control not only the length of the cycle but the frequency of the blink itself:

Pseudocode:

<Visible>(P:Absolute time,seconds) "seed" % "blink lapse" > !</Visible>

The seed parameter is the total length of the blinking cycle. For example, if you want something to blink once every second, you use 1, if you want it blink every half a second, use 0.5 , every two seconds, 2 ,etc.

For each seed, you can determine how long would be the duration of both the visible and invisible part. Then:

(P:Absolute time,seconds) 1 % 0.5 > ! 

this will make the visible and invisible parts of half a second each.

(P:Absolute time,seconds) 1 % 0.7 > ! 

this will make the visible part 70% of the cycle (0.7 secs) and invisible parts of 30 % (0.3 secs).

(P:Absolute time,seconds) 0.5 % 0.25 > ! 

this will make the visible and invisible parts a quarter of second each. You can invert the cycle by removing the "!" char.