[Resolved] How to display score with commas?

I need to display a comma-delineated score on the screen. How do I do that? I assume I convert the score to a string to start.

I know this question has been answered here in the forums before, but I can’t find the topic. How do you search the new forum? [import]uid: 76002 topic_id: 31643 reply_id: 331643[/import]

Try this:
scoreText = display.newText("", 0, 0, native.systemFont, 14)
score1 = 10
score2 = 20
scoreText.text = score1…" , "… score2 [import]uid: 81853 topic_id: 31643 reply_id: 126385[/import]

If your meaning is to covert for example 1000 into 1,000 and such. I use this code I found on google in my current app. I left the credit in the code.

function commaIt(n) -- credit http://richard.warburton.it local left,num,right = string.match(n,'^([^%d]\*%d)(%d\*)(.-)$') if left ~= nil and num ~= nil and right ~= nil then return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right else return n end end [import]uid: 56820 topic_id: 31643 reply_id: 126396[/import]

I use this function I got from lua-users.org. Cheers. Naomi

-- Formatting numbers (1000 --\> 1,000) -- copied from http://lua-users.org/wiki/FormattingNumbers local function comma\_value(amount) local formatted = amount while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end return formatted end [import]uid: 67217 topic_id: 31643 reply_id: 126403[/import]

Thanks! [import]uid: 76002 topic_id: 31643 reply_id: 126404[/import]

Try this:
scoreText = display.newText("", 0, 0, native.systemFont, 14)
score1 = 10
score2 = 20
scoreText.text = score1…" , "… score2 [import]uid: 81853 topic_id: 31643 reply_id: 126385[/import]

If your meaning is to covert for example 1000 into 1,000 and such. I use this code I found on google in my current app. I left the credit in the code.

function commaIt(n) -- credit http://richard.warburton.it local left,num,right = string.match(n,'^([^%d]\*%d)(%d\*)(.-)$') if left ~= nil and num ~= nil and right ~= nil then return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right else return n end end [import]uid: 56820 topic_id: 31643 reply_id: 126396[/import]

I use this function I got from lua-users.org. Cheers. Naomi

-- Formatting numbers (1000 --\> 1,000) -- copied from http://lua-users.org/wiki/FormattingNumbers local function comma\_value(amount) local formatted = amount while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end return formatted end [import]uid: 67217 topic_id: 31643 reply_id: 126403[/import]

Thanks! [import]uid: 76002 topic_id: 31643 reply_id: 126404[/import]