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

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -