Advertisement
Short_Circuit

Lua Timer

Aug 11th, 2014
405
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. Short Circuit's Lua Timer applet
  3. Time cap: 99 hours, 59 minutes, 59 seconds
  4. ]]--
  5.  
  6. function sleep( n )
  7.     if n > 0 then
  8.         os.execute( "ping -n " .. tonumber( n + 1 ) .. " localhost > NUL" )
  9.     end
  10. end
  11.  
  12. -- Init varialbes
  13. s1, s2, m1, m2, h1, h2 = 0, 0, 0, 0, 0, 0
  14.  
  15. os.execute( "color F" )
  16. while true do
  17.     if s1 > 9 then
  18.         s1 = 0
  19.         s2 = s2 + 1
  20.     end
  21.     if s2 > 5 then
  22.         s2 = 0
  23.         m1 = m1 + 1
  24.     end
  25.     if m1 > 9 then
  26.         m1 = 0
  27.         m2 = m2 + 1
  28.     end
  29.     if m2 > 5 then
  30.         m2 = 0
  31.         h1 = h1 + 1
  32.     end
  33.     if h1 > 9 then
  34.         h1 = 0
  35.         h2 = h2 + 1
  36.     end
  37.     if h2 == 9 and h1 == 9 and m2 == 5 and m1 == 9 and s2 == 5 and s1 == 9 then
  38.         print( "Time cap reached!" )
  39.         os.execute( "pause" )
  40.     end
  41.  
  42.     os.execute( "cls" )
  43.     print( "Time elapsed:   " .. h2 .. h1 .. ":" .. m2 .. m1 .. ":" .. s2 .. s1 )
  44.     print( "Time remaining: " .. 9 - h2 .. 9 - h1 .. ":" .. 5 - m2 .. 9 - m1 .. ":" .. 5 - s2 .. 9 - s1 )
  45.     sleep( 1 )
  46.     s1 = s1 + 1
  47. end
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement