Module:GetRandomCreature

From Caves of Qud Wiki
Revision as of 00:37, 16 June 2019 by Teamtoto (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:GetRandomCreature/doc

local p = {}

--[[function p.parse(frame)
local a = string.gsub(frame.args[1],"(&amp;)(%w)([^&\n]+)", "<test span style=\"color: " .. tostring(p.test("%2")) .. ";\">"  .. "%3" .. "<test span>")

local n = string.gsub(frame.args[1], "(&amp;)(%w?)([^&\n]+)", "%2")

return a
end

function p.test(z)
local luatable
luatable = luatable or {
 ['r'] = "rgb(128,0,0)",
 ['R'] = "rgb(255,0,0)",
 ['g'] = "rgb(0,128,0)",
 ['G'] = "rgb(0,255,0),
 ['b'] = "rgb(0,0,128)",
 ['B'] = "rgb(51,102,255)",
 ['c'] = "rgb(51,204,204)",
 ['C'] = "rgb(0,255,255)",
 ['m'] = "rgb(128,0,128)",
 ['M'] = "rgb(255,0,255)",
 ['w'] = "rgb(153,51,0)",
 ['W'] = "rgb(255,255,0)",
 ['k'] = "rgb(0,0,0",
 ['K'] = "rgb(128,128,128)",
 ['y'] = "rgb(192,192,192)",
 ['Y'] = "rgb(255,255,255)",
 ['o'] = "#f15f22",
 ['O'] = "#e99f10",
default = "error"}


local b = luatable[z]
return z
end]]
function p.parse(frame)
local a = string.gsub(frame.args[1],"(&amp;)(%w)([^&\n]+)", function(_,color,text)
        local luatable = {
            ['r'] = "#a64a2e",
            ['R'] = "#d74200",
            ['g'] = "#009403",
            ['G'] = "#00c420",
            ['b'] = "#0048bd",
            ['B'] = "#0096ff",
            ['c'] = "#40a4b9",
            ['C'] = "#77bfcf",
            ['m'] = "#b154cf",
            ['M'] = "#da5bd6",
            ['w'] = "#98875f",
            ['W'] = "#cfc041",
            ['k'] = "#0f3b3a",
            ['K'] = "#155352",
            ['y'] = "#b1c9c3",
            ['Y'] = "#FFFFFF",
            ['o'] = "#f15f22",
            ['O'] = "#e99f10"
        }

        return "<test span style=\"color: " .. luatable[color] .. ";\">"  .. text .. "<test span>"
    end)
end

return p