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 48: | Line 48: | ||
end | end | ||
end | end | ||
return (frac[1][1]/frac[1][2])*(frac[2][1]/frac[2][2]) | return frac[1][1] | ||
--return (frac[1][1]/frac[1][2])*(frac[2][1]/frac[2][2]) | |||
end | end | ||
Line 59: | Line 60: | ||
-- @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 78: | ||
if fmt == "f" then | if fmt == "f" then | ||
if wholeFractions[rate] == nil then | if wholeFractions[rate] == nil then | ||
local digits | |||
-- Set maximum number of decimal places | -- Set maximum number of decimal places | ||
if | if 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 | elseif rate < 100 then | ||
-- Displays with one place between 10.1 ~ 99.9 | -- Displays with one place between 10.1 ~ 99.9 | ||
digits = | digits = 1 | ||
else | |||
-- Otherwise just displays the whole number at 100+ | |||
digits = 0 | |||
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 113: | Line 115: | ||
local rate = {} | local rate = {} | ||
rate[1] = frame.args[2] | rate[1] = frame.args[2] | ||
rate[2] = frame.args[3] | |||
local out = "" | local out = "" | ||
if fmt == "f" then | if fmt == "f" then | ||
Line 133: | Line 128: | ||
span | span | ||
:addClass("more_info") | :addClass("more_info") | ||
:attr("title", string.format("Drop Rate: %s (%s) | :attr("title", string.format("Drop Rate: %s (%s)
Rare Rate: %s (%s)", fmtRate(rate[1], "f"), fmtRate(rate[1], "p"), fmtRate(rate[2], "f", 2), fmtRate(rate[2], "p"))) | ||
:css("border-bottom", "1px dotted") | :css("border-bottom", "1px dotted") | ||
:wikitext(string.format("%s", fmtRate(calcRate(rate[1], rate[2]), "f"))) | :wikitext(string.format("%s", fmtRate(calcRate(rate[1], rate[2]), "f"))) |