Module:ColoredBits: Difference between revisions

Created page with "function p.parse(frame) local a = string.gsub(frame.args[1],"(%w)", function(bit) local luatable = { ['1'] = "#a64a2e", ['A'] = "#d74200",..."
 
mNo edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
function p.parse(frame)
function p.parse(frame)
local a = string.gsub(frame.args[1],"(%w)", function(bit)
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 13: Line 16:
             ['6'] = "#cfc041",
             ['6'] = "#cfc041",
             ['5'] = "#155352",
             ['5'] = "#155352",
             ['7'] = "#FFFFFF",
             ['7'] = "#ffffff",
         }
         }
 
        local result= luatable[bit]
         return "<span style=\"color: " .. luatable[bit] .. ";\">"  .. bit .. "</span>"
        if result == nil then
          result='white'
        end
         return "<span style=\"color: " .. result .. ";\">"  .. bit .. "</span>"
     end)
     end)
return a
return a
end
end
return p