Hi Guys & Gals,
If you are starting with some PRPL, and you are making a unit that has a count down timer, here's a pretty one you can use*. Thanks to GoodMorning and PlanetFall for finding my faults and helping me fix them.
# --Countdown-- 10/9/2016 7:31:14 PM
once
$Time:3600 #Time is equal to total seconds * 30
<-Time ->CountingDown
$TimerPosition:15 #Positive timer shows above node, 0 on top of node, Negative below node
$DeathAtZero:0 #Node is destroyed once countdown hits 0
$SelfDestructType:2 #Decides the type of self destruction (sounds/visual effects)
#Other Needed Variables Below:
#--- --- ---
#--- --- ---
endonce
#Proper numbering of the timer
<-CountingDown 1800 div ->Minutes
<-CountingDown 1800 mod ->A
<-A 30 div 10 lt if
concat(0 <-A 30 div) ->Seconds
else
<-A 30 div ->Seconds
endif
SetText(<-Minutes ":" concat <-Seconds concat)
<-TimerPosition SetTextY #
#Countdown by single fram
<-CountingDown 1 sub ->CountingDown
#Resetting time at countdown finish + whatever countdown triggers
<-CountingDown eq0 if
<-DeathAtZero if
Self <-SelfDestructType DestroyUnit
endif
<-Time ->CountingDown
#Enter code for whatever happens Below:
#--- --- ---
#--- --- ---
endif
:Destroyed #What happens if it goes boom!
#Put code here
#---Credits---
#Base Code: Sorrontis
#Corrections: GoodMorning & planetfall
*Additional code required to make it actually do something other than count.