Hello,
For a string with a single float you can play a bit with the output of
string.format. The following few lines strip all the trailing zeroes
from strings that look a formatted float:
====
function string.optimize_format(form, ...)
local formatted_string = string.format(form, ...)
local optimized_string = formatted_string:gsub('^(%d*\.%d-)(0*)$', '%1')
return optimized_string
end
print(string.optimize_format(0.003))
print(string.optimize_format(0.000007))
print(string.optimize_format(120))
print(string.optimize_format("Hello, world!"))
====
but of course this doesn't work if you have a format like "%s %s l"; you would
have to parse all the arguments to format.
Arthur
_______________________________________________
dev-context mailing list
[email protected]
http://www.ntg.nl/mailman/listinfo/dev-context