I want to convert numbers into their word format, so for example 10 into ten.
Is there a method I can use?
you probably have to do it manually
I recommend a dictionary
Use a dictionary how? I think table would be better
dictionary is like a table but everything is assigned a value like this
local numbers = {
1 = “one”,
2 = “two”,
3 = “three”
}
also yeah looking back you could also use a table cuz the index value would be numbers so you could use a table it would easier
Yes I know what dictionary is but I see why you thought dictionary was good choice.
Use tostring(yourNumber)
Does that just convert it to string or turn into word format
I don’t understand what you mean by a word format but it convets a number into a string like :
the number 11 would be tostring(11) -- Equal to "11"
That’s not what he wants to achieve, read the topic carefully:
The (best) way to do this is to manually use a table, either:
An array containing the word format in order from 1 and just search it up with the number input as the index, for example {“one”, “two”, …}
Or a dictionary of any number like {4 = “four”, 7 = “seven”, …} then search it up with the number input
You could have a dictionary for every unit in a bunch of places (1, 10, 100, etc.) and just see which number is in every place in the entire number then convert it to a string back to front
It could get a bit messy especially in the thousands where the only distinction is a number in front of “thousand” but you could probably fix that with some automated table stuff.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.