| Latest revision |
Your text |
| Line 111: |
Line 111: |
| local slot_colors = { | | local slot_colors = { |
| ["Weapon"] = { | | ["Weapon"] = { |
| hex = "c8761c", | | hex = "c97a03", |
| rgb = "200, 118, 28", | | rgb = "201,122,3", |
| hsl = "31, 75%, 45%", | | hsl = "35,97%,40%", |
| cmyk = "0%, 41%, 86%, 22%" | | cmyk = "0%,39%,98%,21%" |
| }, | | }, |
| ["Armor"] = { | | ["Armor"] = { |
| hex = "6f8724", | | hex = "659818", |
| rgb = "198, 248, 114", | | rgb = "101,152,24", |
| hsl = "82, 91%, 71%", | | hsl = "82,73%,34%", |
| cmyk = "20%, 0%, 54%, 3%" | | cmyk = "34%,0%,84%,40%" |
| }, | | }, |
| ["Tech"] = { | | ["Tech"] = { |
| hex = "ba5ca6", | | hex = "c288f0", -- purple |
| rgb = "186, 92, 166", | | rgb = "194,136,240", |
| hsl = "313, 41%, 55%", | | hsl = "276,79%,74%", |
| cmyk = "0%, 51%, 11%, 27%" | | cmyk = "19%,43%,0%,6%" |
| } | | } |
|
| |
|
| Line 234: |
Line 234: |
| end | | end |
| return false | | return false |
| end
| |
|
| |
| -- Expands multiple of the same template in a single preprocess call
| |
| -- Example:
| |
| -- expand_teampltes(frame, 'HeroIcon', {hero_atlas: {'Abrams'}, hero_bebop: {'Bebop'})
| |
| -- Returns {hero_atlas: <abrams_icon_template>, hero_bebop: <bebop_icon_template>, ...}
| |
| function p.expand_templates(frame, template_name, args_map)
| |
| local keys = {}
| |
| local strings = {}
| |
| for key, args in pairs(args_map) do
| |
| keys[#keys + 1] = key
| |
| end
| |
| for i, key in ipairs(keys) do
| |
| local args = args_map[key]
| |
| local parts = {"{{", template_name, "|"}
| |
| for j, arg in ipairs(args) do
| |
| if j > 1 then parts[#parts + 1] = "|" end
| |
| parts[#parts + 1] = arg
| |
| end
| |
| parts[#parts + 1] = "}}"
| |
| strings[i] = table.concat(parts)
| |
| end
| |
| local expanded = mw.text.split(
| |
| frame:preprocess(table.concat(strings, "\x01")), "\x01"
| |
| )
| |
| local result = {}
| |
| for i, key in ipairs(keys) do
| |
| result[key] = expanded[i]
| |
| end
| |
| return result
| |
| end
| |
|
| |
| -- Helper function
| |
| -- Returns true or false depending if the page exist
| |
| function p.page_exists(title_text)
| |
| local title_obj = mw.title.new(title_text)
| |
| return title_obj and title_obj.exists or false
| |
| end | | end |
|
| |
|
| return p | | return p |