"its very hard to understand cause its not using an example related to my situation"
Ah, my apologies for not explaining the usage thoroughly. Hopefully this will help you.
String.format is a function that manipulates string data by formatting it according to the first argument provided.
Here is an example:
S = "1.123456789";
string.format("%.3f",S);
print(S); --This would print "1.123";
Within the example that I provided, I have a string known as "1.123456789"
The first argument within the string.format function, ".3f", will inform the interpreter that "S" has decimal values that need to be shortened to only the first three decimal numbers.
"S", the second argument of the string.format function within the parentheses, is the actual string that needs to be modified accordingly.
"f" refers to floating-point numerical data, which are decimal data values in C, the language that Lua is constructed from.
If you wanted to determine which values should be omitted, you can simply use an expression such as "%.1f", which informs the interpreter that you would like to remove all decimal values after the first decimal number within the string.
Hopefully this explanation assists you. |