Altamurenza

Bully SE: Timer

Jan 26th, 2018
591
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. -- Timer
  2.  
  3. -- Data:
  4. local gData {
  5.     SystemIsLoaded = false,
  6.     Timer = GetTimer(),Sec = 0,Minute = 0,Hour = 0
  7. }
  8. -- Main function:
  9. function main()
  10.     -- Convert function:
  11.     Convert = function(n)
  12.         for i = 0,9 do
  13.             if n == i then
  14.                 return "0"..n
  15.             end
  16.         end
  17.         return n
  18.     end
  19.    
  20.     -- Process:
  21.     while true do
  22.         if not SystemIsLoaded then
  23.             while not SystemIsReady() or AreaIsLoading() do
  24.                 Wait(0)
  25.             end
  26.            
  27.             gData.SystemIsLoaded = true
  28.         else
  29.             -- Timer:
  30.             if gData.Timer + 1000 <= GetTimer() then
  31.                 gData.Sec = gData.Sec + 1
  32.                 if gData.Sec > 60 then
  33.                     gData.Sec,gData.Minute = 0,gData.Minute + 1
  34.                     if gData.Minute > 59 then
  35.                         gData.Minute,gData.Hour = 0,gData.Hour + 1
  36.                     end
  37.                 end
  38.             end
  39.            
  40.             -- Print:
  41.             TextPrintString(Convert(gData.Hour)..":"..Convert(gData.Minute)..":"..Convert(gData.Sec),1,1)
  42.            
  43.             -- Wait:
  44.             Wait(0)
  45.         end
  46.     end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment