Module:Color: Difference between revisions
Appearance
No edit summary |
m fixed |
||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
function p.color(frame) | function p.color(frame) | ||
local keyword = frame.args[1] | local keyword = frame.args[1] | ||
local colType = frame.args[2] | local colType = frame.args[2] | ||
Line 11: | Line 8: | ||
end | end | ||
local key = "pokehero-color-" .. | local key = "pokehero-color-" .. keyword | ||
local colTable | local colTable |
Latest revision as of 17:11, 20 September 2025
Module:Color
This Lua module provides a color lookup system for PokeHero wiki content.
Usage
Use the module in wikitext with:
{{#invoke:Color|color|<keyword>|<colType>}}
keyword
– the keyword associated with the color: "mental", "physical", etc.colType
– the color type you need: "color", "text", etc.
Example
{{#invoke:Color|color|fighting|color}}
This will return the color code for the Fighting type.
Fallback behavior
- If
keyword
orcolType
is not provided → returnsMissing keyword or colType
. - If Module:Color/keywords does not exist → returns
Missing Module:Color/keywords
. - If
keyword
does not exist → returns<keyword> (missing key in Module:Color/keywords)
. - If
keyword
exists but not the associatedcolType
→ returns<keyword> (missing colType <colType> in Module:Color/keywords)
.
Extending
- Add keys following the format
pokehero-color-<keyword>
in Module:Color/keywords.
local p = {}
function p.color(frame)
local keyword = frame.args[1]
local colType = frame.args[2]
if not keyword or not colType then
return "Missing keyword or colType"
end
local key = "pokehero-color-" .. keyword
local colTable
local success, result = pcall(function()
return mw.loadData("Module:Color/keywords")
end)
if success and result then
colTable = result
else
return "Missing Module:Color/keywords"
end
if colTable[key] then
if colTable[key][colType] then
return colTable[key][colType]
else
return key .. " (missing colType " .. colType .. " in Module:Color/keywords)"
end
else
return key .. " (missing key in Module:Color/keywords)"
end
end
return p