In Lua, you can convert a number to a string using the tostring()
function.
tostring(number)
This function requires a number as a mandatory parameter.
This function will return the number as a string value.
In this example, we will convert two different numbers and we will see the differences in the output.
mynumber = 10newstring = tostring(mynumber)print(mynumber, " is a ", type(newstring))mynumber2 = 10.0newstring2 = tostring(mynumber2)print(mynumber2, " is a ", type(newstring2))
10 is a string
10.0 is a string