Can someone help me? I need to convert a number for a maping that gives me a number in that format 0.2 then I need to convert it to a format like that 0,2. Thankful Nickzus.
✓ ANSWER ACCEPTED
Can someone help me to convert numbers? I need to convert a dot number to a comma number.
1 answer
✓ Accepted answer
local num = 0.2
local com = tostring(num)
for i = 1,#com do
com = com:gsub(".",",")
end
First up you have to convert your number to a string, then You put a loop to the amount of the converted number. This is so that it switches any "." to "," with the gsub (will explain in a second)
Gsub switches a to b in a string and returns the finished value example:
String = "Hey world!"
print(String:gsub("Hey","Hello"))
Output: Hello world!
That should work if I understand what you mean.. You can't convert it into a number as 0,2 since that's not a valid number. If this is not what you mean please leave a comment and tell me.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Do not just post joke; explain the reasoning behind your answer. Simply posting code does not help the OP, or asker, to understand the reasoning behind your answer. Why should he do this? Why should he do that? Why did you use a for loop? Why GSub? Your answer is vague.
Heh, that for loop isn't required at all. As its name suggests, 'gsub' is a GLOBAL substitution.