lua - Getting double from a number -
i got number returns in seconds, want know there possible way double number , add string part? here code:
local time = os.time() - lasttime() local min = time / 60 min = tostring(min) min = string.gsub(min, ".", ":") print("you got "..min.." min!") the above file returns: got :::: min!
all looking convert seconds minutes , seconds (more 2:23)
you can use math.modf function.
time = os.time() --get minutes , franctions of minutes minutes, seconds = math.modf(time/60) --change fraction of minute seconds seconds = math.floor((seconds * 60) + 0.5) --print in printf-like way :) print(string.format("you got %d:%d min!", minutes, seconds))
Comments
Post a Comment