daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Dec 12th, 2017 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function flightTimer(seconds) -- function to convert milliseconds to min/sec
  2.     local seconds = tonumber(seconds)
  3.     if seconds <= 0 then
  4.         return "00:00";
  5.         else
  6.         hours = string.format("%02.f", math.floor(seconds/3600));
  7.         mins = string.format("%02.f", math.floor(seconds/60 - (hours*60)));
  8.         secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60));
  9.         return mins..":"..secs
  10.     end
  11. end
  12.  
  13. -- In main loop
  14.  
  15. if(timerGo == 1) then -- If switch is activated
  16.     if(timer) then
  17.         timeNow = system.getTimeCounter()
  18.         timeNow = timeNow / 1000
  19.         timeNow = timeNow - timeStart
  20.         fTimer = flightTimer(timeNow) -- return elapsed time as mm:ss to dispplay
  21.         else
  22.         timer = true
  23.         timeStart = system.getTimeCounter()
  24.         timeStart = timeStart / 1000
  25.     end
  26. end
RAW Paste Data
Top