Numbers to words?

Anyone know if there’s a function that will convert a string of digits to words? Example. 2005 would be two thousand five. I see Lua doesn’t have a function built in to do this. has anyone ever written one? My goal is to develop a system that speaks the player’s score to them since I’m making purely audio-based games. [import]uid: 44633 topic_id: 24966 reply_id: 324966[/import]

I haven’t seen this done but it seems pretty straightforward since the way a number is turned into a word in natural speech is based entirely on what power of ten it is.
If I were doing this, I’d take the number, convert it to a string, split it into a table knowing that the row would then correspond with the decimal place value so, for example, 425 might look like:

theNumber{“5”,“2”,“4”}

…then just have a if-then-else statement for each which says something like “if it’s at row 3 it must be in the hundreds column so take the number and add the word “hundred” after it”. Then concatenate the resulting strings together to get your final sentence:

“4 HUNDRED 20 4” , or in English english “4 HUNDRED AND 20 4”. It’s not entirely that simple, of course, as you’d need to account for numbers between 11 and 19 which are special cases.

Kev [import]uid: 95579 topic_id: 24966 reply_id: 101327[/import]