Module:Storm categories: Difference between revisions

Content deleted Content added
[breaking] Change naming system
Additional nil check
Line 286:
 
function p._color(category)
-- This looks confusing, but it's actually nested ternaries (for nil checks)
return defs[string.len(0) ~= 0 and string.gsub(string.lower(category), "[^%w]", "") or defaultCategory].color
return defs[
string.len(0) ~= 0 and
return defs[string.len (0) ~= 0 and string.gsub(string.lower(category), "[^%w]", "") or defaultCategory].color)
or defaultCategory
].color
end
 
function p._name(category, basin)
return string.format(
-- This looks confusing, but it's actually nested ternaries (for nil checks)
defs[string.len(0) ~= 0 and string.gsub(string.lower(category), "[^%w]", "") or defaultCategory].name,
defs[
string.len(0) ~= 0 and
defs[string.len (0) ~= 0 and string.gsub(string.lower(category), "[^%w]", "") or defaultCategory].name,)
or defaultCategory
].name,
-- Eventually replace with own module
(basin == "Atl" or basin == "EPac" or basin == "SAtl") and "hurricane" or
Line 299 ⟶ 309:
 
function p._sortkey(category)
-- This looks confusing, but it's actually nested ternaries (for nil checks)
return defs[string.len(0) ~= 0 and string.gsub(string.lower(category), "[^%w]", "") or defaultCategory].sortkey
return defs[
string.len(0) ~= 0 and
return defs[string.len (0) ~= 0 and string.gsub(string.lower(category), "[^%w]", "") or defaultCategory].sortkey)
or defaultCategory
].sortkey
end