Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function flightTimer(seconds) -- function to convert milliseconds to min/sec
- local seconds = tonumber(seconds)
- if seconds <= 0 then
- return "00:00";
- else
- hours = string.format("%02.f", math.floor(seconds/3600));
- mins = string.format("%02.f", math.floor(seconds/60 - (hours*60)));
- secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60));
- return mins..":"..secs
- end
- end
- -- In main loop
- if(timerGo == 1) then -- If switch is activated
- if(timer) then
- timeNow = system.getTimeCounter()
- timeNow = timeNow / 1000
- timeNow = timeNow - timeStart
- fTimer = flightTimer(timeNow) -- return elapsed time as mm:ss to dispplay
- else
- timer = true
- timeStart = system.getTimeCounter()
- timeStart = timeStart / 1000
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement