Module:RaritySort: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.getSortValue(rarity | function p.getSortValue(frame) | ||
local rarity = frame.args[1] | |||
if rarity == nil or type(rarity) ~= "string" then | if rarity == nil or type(rarity) ~= "string" then | ||
return "was nil or not string" | return "was nil or not string" |
Revision as of 17:20, 15 May 2025
Documentation for this module may be created at Module:RaritySort/doc
local p = {}
function p.getSortValue(frame)
local rarity = frame.args[1]
if rarity == nil or type(rarity) ~= "string" then
return "was nil or not string"
end
local trimmed = mw.text.trim(rarity)
local lowered = string.lower(trimmed)
if lowered == "always" then
return 1
elseif lowered:match("^1/%d+$") then
return 2
elseif lowered == "rare" then
return 3
elseif lowered == "never" then
return 4
else
return "no match: " .. lowered
end
end
return p