Module:Storm categories: Difference between revisions

Content deleted Content added
Add "severedep"
Add color overrides and include aliases from {{storm colour}}
Line 5:
-- All sortkeys have been guessed. They may be changed by common sense
-- or consensus at [[Wikipedia talk:WikiProject Tropical cyclones]]
local defscats = {
severe = {
color = "ccffff",
Line 52:
},
subdepression = {
color = "00faf45ebaff",
name = "Subtropical depression",
sortkey = 60
},
subdisturbance = {
color = "00faf480ccff",
name = "Subtropical disturbance",
sortkey = 55
Line 162:
},
esvrcyclstorm = {
color = "ff6060ffc140",
name = "Extremely severe cyclonic storm",
sortkey = 30015
},
vsvrcyclstorm = {
color = "ff6060ffffcc",
name = "Very severe cyclonic storm",
sortkey = 30010
Line 292:
-- required.
 
defscats["sty"] = defscats["supertyphoon"]
defscats["strongnwpsevere"] = defscats["severe"]
defscats["swiostsstrong"] = defscats["severe"]
defscats["stsswiosts"] = defscats["severe"]
defscats["severetssts"] = defscats["severe"]
defscats["tyseverets"] = defscats["typhoonsevere"]
defscats["tdty"] = defscats["depressiontyphoon"]
defscats["tstd"] = defscats["stormdepression"]
defscats["nwpstormts"] = defscats["storm"]
defscats["dnwpstorm"] = defscats["depressionstorm"]
defscats["spdepressiond"] = defscats["depression"]
defscats["shemdepressionspdepression"] = defscats["depression"]
defscats["swiodepressionshdepression"] = defscats["depression"]
defscats["spdepressionshemdepression"] = defscats["depression"]
defscats["nwpdepressionswiodepression"] = defscats["depression"]
defscats["swsubdepspdepression"] = defscats["subdepressiondepression"]
defscats["sdnwpdepression"] = defscats["subdepressiondepression"]
defscats["ssswsubdep"] = defscats["subtropicalsubdepression"]
defscats["mdsd"] = defscats["monsoondepressionsubdepression"]
defscats["ptss"] = defscats["potentialsubtropical"]
defscats["postet"] = defscats["potentialextratropical"]
cats["md"] = cats["monsoondepression"]
defs["potentialtropicalcyclone"] = defs["potential"]
defscats["potentialtropicalcyclonept"] = defscats["potential"]
defscats["remnantlowpotentialtropicalcyclone"] = defscats["remnantpotential"]
defscats["rlpotentialtropicalcyclone"] = defscats["remnantpotential"]
defscats["sucspost"] = defscats["sprcyclstormremnant"]
defscats["escsremnantlow"] = defscats["esvrcyclstormremnant"]
defscats["vscsrl"] = defscats["vsvrcyclstormremnant"]
defscats["scssucs"] = defscats["svrcyclstormsprcyclstorm"]
defscats["csescs"] = defscats["niocycloneesvrcyclstorm"]
defscats["ddvscs"] = defscats["deepdepressionvsvrcyclstorm"]
defscats["cyclstormscs"] = defscats["niocyclonesvrcyclstorm"]
defscats["landdepressioncs"] = defscats["niolandniocyclone"]
defscats["landdd"] = defscats["niolanddeepdepression"]
defscats["fiji5cyclstorm"] = defscats["aus5niocyclone"]
defscats["fiji4landdepression"] = defscats["aus4nioland"]
defscats["fiji3land"] = defscats["aus3nioland"]
defscats["fiji2ld"] = defscats["aus2nioland"]
defscats["fiji1fiji5"] = defscats["aus1aus5"]
defscats["difiji4"] = defscats["disturbanceaus4"]
defscats["swiodisturbancefiji3"] = defscats["disturbanceaus3"]
defscats["mtsfiji2"] = defscats["mstormaus2"]
defscats["subfiji1"] = defscats["mstormaus1"]
defscats["swiotctl"] = defscats["tropicalcyclonelow"]
defscats["shem3di"] = defscats["tropicalcyclonedisturbance"]
defscats["shemtcswiodisturbance"] = defscats["tropicalcyclonedisturbance"]
cats["mts"] = cats["mstorm"]
cats["sub"] = cats["mstorm"]
cats["vitc"] = cats["vintense"]
cats["itc"] = cats["intense"]
cats["tc"] = cats["tropicalcyclone"]
cats["swiotc"] = cats["tropicalcyclone"]
cats["shem3"] = cats["tropicalcyclone"]
cats["shemtc"] = cats["tropicalcyclone"]
 
-- Ambiguous color names. This is because {[storm colour}} itself is extremely
-- ambiguous. This is also used to override the output of some codes.
local colors = {
["5"] = cats["cat5"].color,
["4"] = cats["cat4"].color,
["3"] = cats["cat3"].color,
["2"] = cats["cat2"].color,
["1"] = cats["cat1"].color,
["d"] = "80ccff",
["a5"] = cats["aus5"].color,
["a4"] = cats["aus4"].color,
["a3"] = cats["aus3"].color,
["a2"] = cats["aus2"].color,
["a1"] = cats["aus1"].color
}
 
function p.color(frame)
Line 351 ⟶ 375:
end
 
function p._color(categorycolorCode)
-- This looks confusing, but it's actually nested ternaries (for nil checks)
local color = string.len(colorCode) ~= 0 and
return (defs[
string.lengsub(categorystring.lower(colorCode), ~= 0 and"[^%w]", "")
or defaultCategory;
string.gsub(string.lower(category), "[^%w]", "")
or defaultCategory
return colors[color] or defs((cats[color] or cats[defaultCategory]).color)
end
 
function p._name(category, basin)
local name_def = (defscats[
string.len(category) ~= 0 and
string.gsub(string.lower(category), "[^%w]", "")
or defaultCategory
] or defscats[defaultCategory]).name
return type(name_def) == "table" and
(
Line 377 ⟶ 401:
function p._sortkey(category)
-- This looks confusing, but it's actually nested ternaries (for nil checks)
return (defscats[
string.len(category) ~= 0 and
string.gsub(string.lower(category), "[^%w]", "")
or defaultCategory
] or defscats[defaultCategory]).sortkey
end