I haven’t really tried to do this before, but if I had a guess I’d say take the last digit and have a function that determines if that digit requires a “st”, “nd”, “th”, or “rd” at the end of it.
(For example, if you put 23 into the function it’d take the length of the number (convert it to a string) and if the last digit is a 3, it’d know to put “rd” at the end of it if that makes sense.)
i mean yeah it works but is there a more efficient solution to this than just doing this
local str = "20"
local var = "th"
--
if #str == 2 then
local sec = string.sub(str,2,2)
if sec == "1" then
var = "st"
elseif sec == "2" then
var = "nd"
elseif sec == "3" then
var = "rd"
end
end
--
print(str..var)
I hope this post will help.
It shows how to get the last digit of a number and I you can then use conditionals to determine which (rd,th etc) is needed.