Module:GetRandomCreature: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
local p = {}
local p = {}


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


Line 12: Line 12:
local luatable
local luatable
luatable = luatable or {
luatable = luatable or {
  ['r'] = "#a64a2e",
  ['r'] = "rgb(128,0,0)",
  ['R'] = "#d74200",
  ['R'] = "rgb(255,0,0)",
  ['g'] = "#009403",
  ['g'] = "rgb(0,128,0)",
  ['G'] = "#00c420",
  ['G'] = "rgb(0,255,0),
  ['b'] = "#0048bd",
  ['b'] = "rgb(0,0,128)",
  ['B'] = "#0096ff",
  ['B'] = "rgb(51,102,255)",
  ['c'] = "#40a4b9",
  ['c'] = "rgb(51,204,204)",
  ['C'] = "#77bfcf",
  ['C'] = "rgb(0,255,255)",
  ['m'] = "#b154cf",
  ['m'] = "rgb(128,0,128)",
  ['M'] = "#da5bd6",
  ['M'] = "rgb(255,0,255)",
  ['w'] = "#98875f",
  ['w'] = "rgb(153,51,0)",
  ['W'] = "#cfc041",
  ['W'] = "rgb(255,255,0)",
  ['k'] = "#0f3b3a",
  ['k'] = "rgb(0,0,0",
  ['K'] = "#155352",
  ['K'] = "rgb(128,128,128)",
  ['y'] = "#b1c9c3",
  ['y'] = "rgb(192,192,192)",
  ['Y'] = "#FFFFFF",
  ['Y'] = "rgb(255,255,255)",
  ['o'] = "#f15f22",
  ['o'] = "#f15f22",
  ['O'] = "#e99f10",
  ['O'] = "#e99f10",
Line 35: Line 35:
local b = luatable[z]
local b = luatable[z]
return 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
end


return p
return p

Revision as of 00:37, 16 June 2019

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