PhantomCaleb (talk | contribs) No edit summary |
PhantomCaleb (talk | contribs) m (Protected "Module:Color": Critical wiki page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
(No difference)
|
Revision as of 18:40, 4 August 2020
local p = {}
local data = mw.loadData("Module:Color/Data")
function p.Main(frame)
local args = frame:getParent().args
return p.color(args[1], args[2])
end
function p.color(colorId, text)
local colorClass = string.lower(string.gsub(colorId, " ", "-"))
local html = mw.html.create("span")
:addClass("colored-text")
:addClass(colorClass)
:wikitext(text)
return tostring(html)
end
function p.dialogue(game, source, text)
local gameDialogueColors = data.dialogue[string.lower(game)] or {}
local color = gameDialogueColors[source] or gameDialogueColors.default
if color then
local colorId = game .. " " .. color
return p.color(colorId, text)
else
return text
end
end
return p