I use the code below to announce the values of my Elk M1 counters, which are used as timers.
Code:local function FormatForTTS(sSeconds) local nSeconds = tonumber(sSeconds) local sTTS = "" if nSeconds < 60 then return "timer has expired" else nHours = math.floor(nSeconds/3600) if nHours > 1 then wHours = nHours.." hours" end if nHours == 1 then wHours = "1 hour" end if nHours == 0 then wHours = "" end nMins = math.floor(nSeconds/60 - (nHours*60)); if nMins > 1 then wMins = nMins.." minutes" end if nMins == 1 then wMins = "1 minute" end if nMins == 0 then wMins = "" end nSecs = math.floor(nSeconds - nHours*3600 - nMins *60); if nSecs > 1 then wSecs = nSecs.." seconds" end if nSecs == 1 then wSecs = "1 second" end if nSecs == 0 then wSecs = "" end -- putting it all together now if nHours > 0 then sTTS = sTTS .. wHours if nMins > 0 then sTTS = sTTS .. " and " end end if nMins > 0 then sTTS = sTTS .. wMins if nSecs > 0 then sTTS = sTTS .. " and " end end if nSecs > 0 then sTTS = sTTS .. wSecs end return "Time remaining: " .. sTTS end end


Reply With Quote