Time Display in Global Rackspace

I like having the Time displayed on when playing live and having read the thread Time Clock I updated the script so that the time can be included in the global rack space rather than in each rack space. The display is only updated every ā€˜nā€™ seconds and the format can be set as required. The only issue I had getting this to work is the initialisation of the timer, the rack space must be changed once to get the timer started, but once running stays running.

Add a label widget named lbl_time to the global rack space and add the following lines of code to the global rack space script.

var lbl_time : widget
var int_interval : integer = 1          // Update interval in seconds
var str_format : string = "%H:%M:%S"    // Format of the clock display

// Called by timer ticking
On TimerTick(ns : double)
    var dbl_mSeconds : double
    dbl_mSeconds = ClockTime()
    If (Floor(dbl_mSeconds / 500) % (int_interval << 1)) == 0 Then  
        lbl_time.SetWidgetLabel (FormatTime(dbl_mSeconds, str_format))
    End
End

// Called when rackspace is activated
On Rackspace(oldRs : Integer, newRs : Integer )
    If !GetTimersRunning() Then
        SetTimersRunning(true)
    End
End

There may be a better way but this ticks along nicely

3 Likes