Dota 2 Wiki
m (The nowiki tags should only be needed when called from Template:Color not when called from other modules)
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
local p = {}
 
local p = {}
local getArgs = require('Module:Arguments').main
+
local colors = mw.loadData('Module:Color/data')
  +
local getArgs = require('Module:Arguments').getArgs
   
local colors = {
 
-- GENERAL WIKI COLORS
 
["wiki1"] = "#B44335",
 
["wiki2"] = "#CD5F51",
 
["wiki3"] = "#FFAEA3",
 
["wiki4"] = "#FDE6E3",
 
["wiki5"] = "#E4C62E",
 
["wiki6"] = "#E38800",
 
-- DOTA 2 UI
 
["ui1"] = "#1B1E21",
 
["ui2"] = "#2F363D",
 
-- HEROES
 
["strength"] = "#B9500B",
 
["agility"] = "#167C13",
 
["intelligence"] = "#257DAE",
 
["radiant"] = "#598307",
 
["dire"] = "#A83806",
 
["neutral"] = "#434137",
 
-- UNITS
 
["creep"] = "#2277AA",
 
["creep-hero"] = "#FFBE66",
 
["lane creep"] = "#2277AA",
 
["jungle creep"] = "#2277AA",
 
["ancient creep"] = "#2277AA",
 
["summon"] = "#FFBE66",
 
["ward"] = "#64D74A",
 
["building"] = "#2277AA",
 
["other"] = "pink",
 
["courier"] = "#FFBE66",
 
-- ABILITIES
 
["hero"] = "#B44335",
 
["ultimate"] = "#414141",
 
["item"] = "#227722",
 
["npc"] = "#2277AA",
 
["aghanims"] = "#5B388F",
 
["talent"] = "#BDB76B",
 
["rune"] = "#E3B505",
 
-- ITEMS
 
["gold"] = "#DAA520",
 
["armor"] = "#B911FC",
 
["caster"] = "#1A88FC",
 
["support"] = "#1A88FC",
 
["artifacts"] = "#DB9702",
 
["common"] = "#2BAC00",
 
["basic"] = "#FEFEFE",
 
["attributes"] = "#FEFEFE",
 
["armaments"] = "#FEFEFE",
 
["arcane"] = "#FEFEFE",
 
-- COSMETIC ITEMS - RARITY
 
["cos_common"] = "#b0c3d9",
 
["cos_uncommon"] = "#5e98d9",
 
["cos_rare"] = "#4b69ff",
 
["cos_mythical"] = "#8847ff",
 
["cos_legendary"] = "#d32ce6",
 
["cos_ancient"] = "#eb4b4b",
 
["cos_immortal"] = "#b28a33",
 
["cos_arcana"] = "#ade55c",
 
["cos_dota plus access"] = "#fff34f",
 
-- COSMETIC ITEMS - QUALITY
 
["cos_normal"] = "#B2B2B2",
 
["cos_genuine"] = "#4D7455",
 
["cos_elder"] = "#476291", -- Internal name: vintage
 
["cos_unusual"] = "#8650AC",
 
["cos_unique"] = "#D2D2D2",
 
["cos_community"] = "#70B04A",
 
["cos_developer"] = "#A50F79",
 
["cos_selfmade"] = "#70B04A",
 
["cos_customized"] = "#00FF00",
 
["cos_inscribed"] = "#CF6A32", -- Internal name: strange
 
["cos_infused"] = "#8847FF",
 
["cos_completed"] = "#8650AC",
 
["cos_cursed"] = "#8650AC",
 
["cos_heroic"] = "#8650AC", -- Internal name: tournament
 
["cos_favored"] = "#FFFF00",
 
["cos_ascendant"] = "#EB4B4B",
 
["cos_autographed"] = "#ADE55C",
 
["cos_legacy"] = "#FFFFFF",
 
["cos_exalted"] = "#CCCCCC",
 
["cos_frozen"] = "#4682B4",
 
["cos_corrupted"] = "#A52A2A",
 
["cos_auspicious"] = "#32CD32", -- Internal name: lucky
 
["cos_unusual_text"] = "#e4ae39",
 
-- RANKINGS
 
["proceed"] = "#CFC",
 
["up"] = "#CFC",
 
["stayup"] = "#EFA",
 
["stay"] = "#FF9",
 
["staydown"] = "#FDA",
 
["drop"] = "#FCC",
 
["down"] = "#FCC"
 
}
 
   
 
function p.main(frame)
 
local args = getArgs(frame, {
  +
wrappers = {
  +
'Template:Color'
 
}
  +
})
   
  +
local success, result = pcall(p._main, args)
function p.main()
 
 
if success then
local args = getArgs()
 
return mw.text.nowiki(p._main(args))
+
return mw.text.nowiki(result)
end
 
 
function p._main(args)
 
if args[1] then
 
local input = string.lower(args[1])
 
 
-- Make the table return the input if no entry was found.
 
setmetatable(colors, { __index = function() return input end })
 
 
return colors[input]
 
 
else
 
else
 
-- Returning an empty string to prevent old templates from breaking.
 
-- Returning an empty string to prevent old templates from breaking.
-- TODO: Update all templates and remove this (replace with assert).
+
-- TODO: Update all templates.
 
return ''
 
return ''
 
end
 
end
 
end
  +
 
function p._main(args)
  +
assert(args[1], 'Missing input')
  +
return colors[args[1]:lower()] or args[1]
 
end
 
end
   

Latest revision as of 12:49, 20 April 2018

Documentation for Module:Color Jump to code ↴ [ edit | purge ]

Reality Rift icon
▶️ Planeshift.
The documentation for this module can be found at Template:Color.
You may be forwarded to another wiki language, in case a translation is not available.


Dependencies

local p = {}
local colors = mw.loadData('Module:Color/data')
local getArgs = require('Module:Arguments').getArgs


function p.main(frame)
  local args = getArgs(frame, {
    wrappers = {
      'Template:Color'
    }
  })

  local success, result = pcall(p._main, args)
  if success then
    return mw.text.nowiki(result)
  else
    -- Returning an empty string to prevent old templates from breaking.
    -- TODO: Update all templates.
    return ''
  end
end

function p._main(args)
  assert(args[1], 'Missing input')
  return colors[args[1]:lower()] or args[1]
end


return p