Module:RarityHandler: Difference between revisions
No edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
function p.getSortValue(frame) | function p.getSortValue(frame) | ||
local | local raw = frame.args[1] | ||
if not | if not raw or type(raw) ~= "string" then | ||
return 999999999 | return 999999999 | ||
end | end | ||
local rarity = clean(raw) | |||
if not rarity then return 999999999 end | |||
if rarity | |||
local lowered = rarity:lower() | local lowered = rarity:lower() | ||
Line 38: | Line 34: | ||
end | end | ||
-- Match and convert fractional chance like "1/2.5", "1/ | -- Match and convert fractional chance like "1/2.5", "1/10000" | ||
local num = lowered:match("^1/(%d+%.?%d*)$") | local num = lowered:match("^1/(%d+%.?%d*)$") | ||
if num then | if num then | ||
local n = tonumber(num) | local n = tonumber(num) | ||
if n then | if n then | ||
return n | return math.floor(n) | ||
end | end | ||
end | end | ||
return 999999999 | return 999999999 | ||
end | end |