@a1ex
I've concluded that not all the string functions are in Lua. Am I right?
The following simply doesn't work
string.format("%.2f", num)
Confirmed. Oddly enough, using %s for floating-point numbers appears to work.
@a1ex
Thanks for the confirmation and the pointer to %s
@a1ex
I also guess using %s wouldn't allow you to control the decimal place formatting.
Not having %.xf is not an issue as I can achieve the result other ways. For instance in my DoF Bar I do this:
function myround(num,dp)
-- num = a number, dp = decimal places required to show
-- returns number as a string
if dp == 0 then
num = tostring(math.floor(num))
else
--text =
num = tostring(math.floor(num)).."."..string.sub(tostring(math.floor(num*10^dp)),-dp,-1)
end
return num
end