|
|
(38 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| local p = {} | | local p = {} |
| local colorparse = require'Module:ColorParse' | | local cargo = mw.ext.cargo |
|
| |
|
| function p.qudlook(frame) | | function p.a(seed) |
| | | math.randomseed(tonumber(seed)) |
| local bordercolor | | 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 padding
| | local offsetin = math.random(0 , tonumber(count)-2) |
| local bottomtext
| | local tables = 'Characters=C, GeneralData=GD' |
| | | local fields = 'GD.PlainName=Name, GD._pageName=Page' |
| --[Determine border color]--
| | 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 bordercolorin = frame.args.bordercolor
| | local result = cargo.query(tables, fields, args) |
| if bordercolorin == nil or bordercolorin == 'c' then
| | if not next(result) then |
| bordercolor = ''
| | error('?????') |
| elseif bordercolorin == 'y' then
| | end |
| bordercolor='white-border'
| | return '[[' .. result[1]['Page'] .. '|'.. result[1]['Name'] .. ']]' |
| else
| |
| error('bordercolor not set to either "c" or "y"',0)
| |
| end
| |
| | |
| --[Determine Title Color]--
| |
| local titlein= frame.args.title | |
| local title = colorparse.parse('&y'.. titlein) | |
| | |
| --[Determine qud text]--
| |
| local text = frame.args['text'] | |
| local qudtext = frame:extensionTag{ name='poem', content=colorparse.parse('&y' .. text) } | |
| | |
| --[Determine body padding]--
| |
| local paddingin = frame.args.padding | |
| if paddingin == nil or paddingin == '' then | |
| padding = '1.5' | |
| else
| |
| padding = paddingin
| |
| end | | end |
|
| |
|
| --[Determine bottomtext]--
| | function p.getRandomChara(frame) |
| local bottomin = frame.args.bottomtext
| | return p.a(frame.args.seed) |
| if bottomin == nil or bottomin == '' then
| |
| bottomtext= 'Perfect'
| |
| elseif bottomin == 'none' then
| |
| bottomtext= ''
| |
| else
| |
| bottomtext= bottomin
| |
| end | | end |
| local parsedbottomtext=colorparse.parse('&Y'..bottomtext)
| |
|
| |
| --[Return html]--
| |
| local html = {
| |
| '<div class="qud-box-wrapper' ..bordercolor..'">',
| |
| '<div class="qud-box">',
| |
| '<span class="qud-box-header"><b>' .. title .. '</b></span>',
| |
| '<div class="qud-box-content" style="font-weight:bold; line-height:1.5em; padding:0em '..padding..'em;">'..qudtext..'</div>',
| |
| '<span class="qud-box-footer-left">'..parsedbottomtext..'</span></div></div>'
| |
| }
| |
|
| |
|
| return html .. '\n' | | function p.test(seed) |
| | return p.a(tostring(seed)) |
| end | | end |
|
| |
| return p | | return p |