格式化
local seconds = 65
local day = math.floor(seconds / 86400)
seconds = math.fmod(seconds, 86400)
local hour = math.floor(seconds / 3600)
seconds = math.fmod(seconds, 3600)
local min = math.floor(seconds / 60)
local sec = math.fmod(seconds, 60)
if day > 0 then
return string.format("%02d:%02d:%02d:%02d", day, hour, min, sec)
else
return string.format("%02d:%02d:%02d", hour, min, sec);
end
倒数实现
self.maxMatchCd = 65
coroutine.start(function()
local currCd = self.maxMatchCd
self.forceStopMatchCD = false
while true do
coroutine.waitforseconds(1);
currCd = currCd -1
-- do somthing with param:currCd
if self.forceStopMatchCD then
break
end
end
end)
倒数暂停
self.forceStopMatchCD = true;

本文介绍了如何使用lua进行秒数的格式化转换,包括计算本地天数、小时、分钟和秒,以及实现倒数计时功能,并讨论了如何暂停和停止计时过程。

1733

被折叠的 条评论
为什么被折叠?



