Editing Module:Rates/Sandbox
From Ephinea PSO Wiki
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 59: | Line 59: | ||
-- @return {string} | -- @return {string} | ||
-- | -- | ||
local function fmtRate(rate, fmt | local function fmtRate(rate, fmt) | ||
local out = "" | local out = "" | ||
local frac = {} | local frac = {} | ||
Line 77: | Line 77: | ||
if fmt == "f" then | if fmt == "f" then | ||
if wholeFractions[rate] == nil then | if wholeFractions[rate] == nil then | ||
local digits = 0 | |||
-- Set maximum number of decimal places | -- Set maximum number of decimal places | ||
if 1/rate < 10 then | if 1/rate < 10 then | ||
-- Displays with two places between 1.01 ~ 9.99 | -- Displays with two places between 1.01 ~ 9.99 | ||
digits = | digits = 2 | ||
elseif 1/rate < 100 then | elseif 1/rate < 100 then | ||
-- Displays with one place between 10.1 ~ 99.9 | -- Displays with one place between 10.1 ~ 99.9 | ||
digits = | digits = 1 | ||
end | end | ||
-- Even if we're displaying one or more decimal places, cut zeroes off | -- Even if we're displaying one or more decimal places, cut zeroes off | ||
Line 117: | Line 115: | ||
else | else | ||
rate[2] = frame.args[3] | rate[2] = frame.args[3] | ||
end | end | ||
local out = "" | local out = "" |