Module:ColoredBits: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
function p.parse(frame) | function p.parse(frame) | ||
local a = string.gsub(frame.args[1],"( | local a = string.gsub(frame.args[1],"([012345678ABCD])", function(bit) | ||
local luatable = { | local luatable = { | ||
['0'] = "#98875f", | |||
['1'] = "#a64a2e", | ['1'] = "#a64a2e", | ||
['A'] = "#d74200", | ['A'] = "#d74200", | ||
Line 15: | Line 16: | ||
['6'] = "#cfc041", | ['6'] = "#cfc041", | ||
['5'] = "#155352", | ['5'] = "#155352", | ||
['7'] = "# | ['7'] = "#ffffff", | ||
} | } | ||
local result= luatable[bit] | |||
return "<span style=\"color: " .. | if result == nil then | ||
result='white' | |||
end | |||
return "<span style=\"color: " .. result .. ";\">" .. bit .. "</span>" | |||
end) | end) | ||
return a | return a | ||
end | end | ||
return p |
Latest revision as of 19:56, 27 August 2019
local p = {}
function p.parse(frame)
local a = string.gsub(frame.args[1],"([012345678ABCD])", function(bit)
local luatable = {
['0'] = "#98875f",
['1'] = "#a64a2e",
['A'] = "#d74200",
['2'] = "#009403",
['B'] = "#00c420",
['3'] = "#0048bd",
['C'] = "#0096ff",
['4'] = "#40a4b9",
['D'] = "#77bfcf",
['8'] = "#da5bd6",
['6'] = "#cfc041",
['5'] = "#155352",
['7'] = "#ffffff",
}
local result= luatable[bit]
if result == nil then
result='white'
end
return "<span style=\"color: " .. result .. ";\">" .. bit .. "</span>"
end)
return a
end
return p