Module:Achievement set requirements adv
Documentation for this module may be created at Module:Achievement set requirements adv/doc
-- <pre>
-- {{Achievement_set_requirements_adv}}
--
local p = {}
local yesno = require( 'Module:Yesno' )
local onmain = require('Module:Mainonly').on_main()
function p.details( frame )
local _args = frame:getParent().args
local tbl = mw.html.create( 'table' )
local title = mw.uri.fullUrl( mw.title.getCurrentTitle().fullText, { action = 'edit' } )
local unknown = 'Unknown <small>[' .. tostring( title ) .. ' edit]</small>'
local args = {}
for k, v in pairs(_args) do
if v ~= '' then
args[k] = v
end
end
local reqs = args.skills or '* None'
local quests = args.quests or '* None'
local items = args.items or '* None'
local checklist = items
if items ~= '* None' then
checklist = '<div class="lighttable checklist">\n'..items..'</div>' --frame:expandTemplate{ title = 'Checklist', args = { items } }
end
tbl
:addClass( 'mw-collapsible mw-collapsed' )
:tag( 'tr' )
:tag( 'th' )
:wikitext( 'Required skills' )
:done()
:done()
:tag( 'tr' )
:tag( 'td' )
:addClass( 'qc-active' )
:tag( 'i' )
:wikitext( 'Skill requirements are not boostable unless marked with a [B] for boostable.' )
:done()
:newline():newline()
:wikitext( reqs )
:done()
:done()
:done()
:done()
:done():done():done()
:wikitext( '</table>')
:wikitext( '<table class="mw-collapsible mw-collapsed">' )
:tag( 'tr' )
:tag( 'th' )
:wikitext( 'Required quests' )
:done()
:done()
:tag( 'tr' )
:tag( 'tr' )
:tag( 'td' )
:addClass( 'qc-active' )
:tag( 'i' )
:newline():newline()
:wikitext( quests )
:done()
:done()
:done()
:done()
:done()
:wikitext( '</table>')
:wikitext( '<table class="mw-collapsible mw-collapsed">' )
:tag( 'tr' )
:tag( 'th' )
:wikitext( 'Required items' )
:done()
:done()
:tag( 'tr' )
:tag( 'tr' )
:wikitext( '<td nowrap="nowrap>' )
:tag( 'i' )
:wikitext( 'Items from the [[tool belt]] are not listed unless they do not work or are not automatically added.' )
:done()
:newline():newline()
:wikitext( checklist )
:done()
:done()
:wikitext( '</table>')
if args.recommendeditems ~= nil and yesno( args.recommendeditems ) ~= false then
tbl
:addClass( 'mw-collapsible mw-collapsed' )
:wikitext( '<table class="mw-collapsible mw-collapsed">' )
:tag( 'tr' )
:tag( 'th' )
:wikitext( 'Reccomended items' )
:done()
:done()
:tag( 'tr' )
:wikitext( '<td nowrap="nowrap>' )
:newline():newline()
:wikitext( '<div class="lighttable checklist">\n'..args.recommendeditems ..'</div>') -- frame:expandTemplate{ title = 'Checklist', args = { args.recommended } } )
:done()
:done()
:done()
:wikitext( '</table>')
end
return tostring( tbl ) .. smw(frame,_args)
end
function smw(frame,args)
if not onmain then
return ''
end
-- more to come
local err = mw.html.create('div')
err:addClass('hidden'):css('display','none')
local haserr = false
local info = ''
local smwJSON = {
name = mw.title.getCurrentTitle().text,
skills = args.skills or 'None',
items = args.items or 'None',
quests = args.quests or 'None',
}
local jsongood, encsmwJSON = pcall(mw.text.jsonEncode, smwJSON)
if jsongood then
-- for easier debug, please do not remove
encsmwJSON = mw.text.nowiki(encsmwJSON)
local div = mw.html.create('div')
div :addClass('hidden')
:css('display', 'none')
:wikitext('[[Quest JSON::'..encsmwJSON..']]')
info = frame:preprocess(tostring(div))
else
haserr = true
err:wikitext('Error setting SMW JSON, string: ' .. mw.dumpObject(smwJSON))
end
if not haserr then
err = ''
end
return tostring(info) .. tostring(err)
end
return p