Module:GetRandomCreature: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(140 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}
local table = {
local cargo = mw.ext.cargo
r = "#a64a2e",
 
R = "#d74200",
function p.a(seed)
g = "#009403",
  math.randomseed(tonumber(seed))
G = "#00c420",
  local count = cargo.query('Characters=C, GeneralData=GD', 'TRIM(COUNT(C._pageName))=Number', {join='C.ObjectID=GD.ObjectID', where='C._pageNamespace="0" AND (NOT GD.ParentObject WITHIN "Wall" AND NOT GD.PlainName LIKE "* door")'})[1]['Number']
b = "#0048bd",
  local offsetin = math.random(0 , tonumber(count)-2)
B = "#0096ff",
  local tables = 'Characters=C, GeneralData=GD'
c = "#40a4b9",
  local fields = 'GD.PlainName=Name, GD._pageName=Page'
C = "#77bfcf",
  local args ={join='C._pageName=GD._pageName', where='GD._pageNamespace="0" AND (NOT GD.ParentObject WITHIN "Wall" AND NOT GD.PlainName LIKE "* door")', offset=offsetin,limit = 1}
m = "#b154cf",
  local result = cargo.query(tables, fields, args)
M = "#da5bd6",
  if not next(result) then
w = "#98875f",
    error('?????')
W = "#cfc041",
  end
k = "#0f3b3a",
  return '[[' .. result[1]['Page'] .. '|'.. result[1]['Name'] .. ']]'
  K = "#155352",
end
y = "#b1c9c3",
 
Y = "#FFFFFF",
function p.getRandomChara(frame)
o = "#f15f22",
  return p.a(frame.args.seed)
O = "#e99f10"}
end
function p.parse(frame)
 
local a = string.gsub(frame.args[1],"(&amp;)(%w)([^&\n]+)", "<span style=\"color: " .. "table[%2]" .. ";\">%3</span>")
function p.test(seed)
    return a;
  return p.a(tostring(seed))
end
end
return p
return p

Latest revision as of 14:42, 27 July 2023

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

local p = {}
local cargo = mw.ext.cargo

function p.a(seed)
  math.randomseed(tonumber(seed))
  local count = cargo.query('Characters=C, GeneralData=GD', 'TRIM(COUNT(C._pageName))=Number', {join='C.ObjectID=GD.ObjectID', where='C._pageNamespace="0" AND (NOT GD.ParentObject WITHIN "Wall" AND NOT GD.PlainName LIKE "* door")'})[1]['Number']
  local offsetin = math.random(0 , tonumber(count)-2)
  local tables = 'Characters=C, GeneralData=GD'
  local fields = 'GD.PlainName=Name, GD._pageName=Page'
  local args ={join='C._pageName=GD._pageName', where='GD._pageNamespace="0" AND (NOT GD.ParentObject WITHIN "Wall" AND NOT  GD.PlainName LIKE "* door")', offset=offsetin,limit = 1}
  local result = cargo.query(tables, fields, args)
  if not next(result) then
    error('?????')
  end
  return '[[' .. result[1]['Page'] .. '|'.. result[1]['Name'] .. ']]'
end

function p.getRandomChara(frame)
  return p.a(frame.args.seed)
end

function p.test(seed)
  return p.a(tostring(seed))
end
return p