scope GameClock
globals
private multiboarditem i
private integer c=0
endglobals
private function Deciseconds takes nothing returns string
if ModuloInteger(c,100)>9 then
return I2S(ModuloInteger(c,100))
else
return "0"+I2S(ModuloInteger(c,100))
endif
endfunction
private function Seconds takes nothing returns string
if ModuloInteger(c/100,60)>9 then
return I2S(ModuloInteger(c/100,60))
else
return "0"+I2S(ModuloInteger(c/100,60))
endif
endfunction
private function Minutes takes nothing returns string
if ModuloInteger(c/6000,60)>9 then
return I2S(ModuloInteger(c/6000,60))
else
return "0"+I2S(ModuloInteger(c/6000,60))
endif
endfunction
private function Hours takes nothing returns string
if c/360000>9 then
return I2S(c/360000)
else
return "0"+I2S(c/360000)
endif
endfunction
private function Timer takes nothing returns nothing
set c=c+1
call MultiboardSetItemValue(i,Hours()+":"+Minutes()+":"+Seconds()+":"+Deciseconds())
endfunction
private function Actions takes nothing returns nothing
local multiboard m=CreateMultiboard()
call MultiboardSetTitleText(m,"Game Clock")
call MultiboardSetTitleTextColor(m,100,100,255,0)
call MultiboardSetColumnCount(m,1)
call MultiboardSetRowCount(m,1)
call MultiboardDisplay(m,true)
set i=MultiboardGetItem(m,0,0)
call MultiboardSetItemWidth(i,.06)
call MultiboardSetItemValueColor(i,0,255,0,0)
call MultiboardSetItemStyle(i,true,false)
call TimerStart(CreateTimer(),0.01,true,function Timer)
call DestroyTrigger(GetTriggeringTrigger())
set m=null
endfunction
//===========================================================================
function InitTrig_GameClock takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterTimerEvent(t,0,false)
call TriggerAddAction(t,function Actions)
set t=null
endfunction
endscope