8,758
edits
mNo edit summary |
mNo edit summary |
||
(67 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
local cargo = mw.ext.cargo | local cargo = mw.ext.cargo | ||
function p. | function p.a(seed) | ||
local | math.randomseed(tonumber(seed)) | ||
local | 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'] | ||
return | 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 | end | ||
function p. | function p.getRandomChara(frame) | ||
return p.a(frame.args.seed) | |||
end | |||
function p.test(seed) | |||
return p.a(tostring(seed)) | |||
return a | |||
end | end | ||
return p | return p |