Module:Storm categories: Difference between revisions

Content deleted Content added
Fix checks
Support table name definitions
Line 66:
cat5 = {
color = "ff6060",
name = "Category 5 %s",{
Atl = "Category 5 hurricane",
EPac = "Category 5 hurricane",
SAtl = "Category 5 hurricane",
WPac = "Category 5 super typhoon",
(basindefault == "WPac"Category and5 "typhooon" or "tropical cyclone")
},
sortkey = 10010
},
cat4 = {
color = "ff8f20",
name = "Category 4 %s",{
Atl = "Category 4 hurricane",
EPac = "Category 4 hurricane",
SAtl = "Category 4 hurricane",
WPac = "Category 4 super typhoon",
default = "Category 4 tropical cyclone"
},
sortkey = 10008
},
cat3 = {
color = "ffc140",
name = "Category 3 %s",{
Atl = "Category 3 hurricane",
EPac = "Category 3 hurricane",
SAtl = "Category 3 hurricane",
WPac = "Category 3 super typhoon",
default = "Category 3 tropical cyclone"
},
sortkey = 10006
},
cat2 = {
color = "ffe775",
name = "Category 2 %s",{
Atl = "Category 2 hurricane",
EPac = "Category 2 hurricane",
SAtl = "Category 2 hurricane",
WPac = "Category 2 super typhoon",
default = "Category 2 tropical cyclone"
},
sortkey = 10004
},
cat1 = {
color = "ffffcc",
name = "Category 1 %s",{
Atl = "Category 1 hurricane",
EPac = "Category 1 hurricane",
SAtl = "Category 1 hurricane",
WPac = "Category 1 super typhoon",
default = "Category 1 tropical cyclone"
},
sortkey = 10002
},
Line 295 ⟶ 325:
 
function p._name(category, basin)
local name_def = (defs[
return string.format(
string.len(category) ~= 0 and
-- This looks confusing, but it's actually nested ternaries (for nil checks)
string.gsub(string.lower(category), "[^%w]", "")
(defs[
or defaultCategory
string.len(category) ~= 0 and
] or defs[defaultCategory]).name,
string.gsub(string.lower(category), "[^%w]", "")
return type(name_def) == "table" and
or defaultCategory
(
] or defs[defaultCategory]).name,
name_def[basin]
-- Eventually replace with own module
or name_def["default"]
(basin == "Atl" or basin == "EPac" or basin == "SAtl") and "hurricane" or
or error("No default name for basin-based category name.")
(basin == "WPac" and "typhooon" or "tropical cyclone")
)
)
or name_def
end