I can’t seem to find the right string.format parameter to display the 0 before single digit.
I need to display this 09:03 instead of 9:3
Can anyone help?
[import]uid: 8192 topic_id: 7393 reply_id: 307393[/import]
I can’t seem to find the right string.format parameter to display the 0 before single digit.
I need to display this 09:03 instead of 9:3
Can anyone help?
[import]uid: 8192 topic_id: 7393 reply_id: 307393[/import]
print( string.format("%02d:%02d", 9, 3 ) ) [import]uid: 12088 topic_id: 7393 reply_id: 26094[/import]
Yes!!! Thank you very much! [import]uid: 8192 topic_id: 7393 reply_id: 26096[/import]
Perfect question!
How about getting zeros in this context?
local hiScoreText = display.newText( hiScore,100, 10, native.systemFontBold, 18)
I am trying to do something like: 0000002540 where hiscore = 2540 for instance. I tried:
local hiScoreText = display.newText(string.format("%06d", hiScore),100, 10, native.systemFontBold, 18)
AND
local hiScoreText = display.newText( “%06d”…hiScore,100, 10, native.systemFontBold, 18)
But no luck. All this does is move the hiScore a little bit to the right but no zeros in the front of the hiScore
Any ideas?
Thanks a lot.
Mo
[import]uid: 49236 topic_id: 7393 reply_id: 52372[/import]
[lua] local hiscore = 2540
local hiScoreText = display.newText( string.format ( “%010d”, hiscore ),100, 10, native.systemFontBold, 18)[/lua]
[import]uid: 13632 topic_id: 7393 reply_id: 52383[/import]
THANKS ojnab!!!
As usual you guys rock in this forum. Work like a charm. I was also forgetting to format my hiscore/score updates so of course at the start your solution did not “work”. For newbie (like me) out there make sure your format your updates like:
hiScoreText.text = string.format ( “%010d”, hiScore )
Thanks again ojnab. I appreciate it.
Mo
[import]uid: 49236 topic_id: 7393 reply_id: 52386[/import]