Module:QuestDetails: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
No edit summary
mNo edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1:
local p = {}
 
local Infobox = require('Module:Infobox')
local parse = require('Module:Param Parse')
 
function p.details(frame)
local args = frame:getParent().args
local mw = require('mw')
if args.start_point then
local config = {
mw.smw.set({
infobox_name = 'QuestDetails',
["start_point"] = args.start_point,
class = 'questdetails',
})
}
end
if args.requirements then
mw.smw.set({
["requirements"] = '\n'..args.requirements,
})
end
if args.recommended then
mw.smw.set({
["recommended"] = '\n'..args.recommended,
})
end
if args.enemies then
mw.smw.set({
["enemies"] = args.enemies,
})
end
local requirements;
if (args.requirements) then
requirements = args.requirements
else
requirements = 'None'
end
local paramstable = {mw.html.create( 'table' )
table
{name = 'start_point', func = parse.has_content, smw_property = 'Start Point'},
:attr( 'class', 'wikitable plainlinks' )
{name = 'requirements', func = parse.has_content, smw_property = 'Requirements'}
:attr( 'cellspacing', '3' )
}
:tag( 'tr' )
:tag( 'td' )
local infobox = Infobox.new(config, params, args)
:tag( 'b' )
local auto_width = { ["max-width"] = "85%", ["width"] = "auto" }
:wikitext('Start Point')
infobox
:done()
:add_row{
:attr('style', 'vertical-align:top; width:15%; padding: 1em;')
{ tag = 'th', class = "questdetails-header", content = 'Start Point' },
:done()
{ tag = 'td', class = "questdetails-info", content=Infobox.param('start_point'), css = auto_width }
:tag( 'td' )
}
:tag('p')
:add_row{
:wikitext( args['start_point'] )
{ tag = 'th', class = "questdetails-header", content = 'Requirements' },
:done()
{tag = 'td', class = "questdetails-info", content=Infobox.param('requirements'), colspan='2' },
:attr('style', 'max-width:85%; width:auto; padding-left: 1em; padding-right: 2em;')
}
:done()
:done()
return infobox
:tag( 'tr' )
:tag( 'td' )
:tag( 'b' )
:wikitext('Requirements')
:done()
:attr('style', 'vertical-align:top; width:15%; padding: 1em;')
:done()
:tag( 'td' )
:tag('div')
:addClass('lighttable checklist')
:newline()
:wikitext(requirements)
:attr('style', 'max-width:85%; width:auto; padding: 0.3em;')
:done()
:done()
if (args.recommended) then
table
:tag( 'tr' )
:tag( 'td' )
:tag( 'b' )
:wikitext('Recommended')
:done()
:attr('style', 'vertical-align:top; width:15%; padding: 1em;')
:done()
:tag( 'td' )
:tag('div')
:newline()
:wikitext( args.recommended )
:attr('style', 'max-width:85%; width:auto; padding-left: 1em; padding-right: 2em;')
:done()
:done()
end
if (args.enemies) then
table
:tag( 'tr' )
:tag( 'td' )
:tag( 'b' )
:wikitext('Enemies')
:done()
:attr('style', 'vertical-align:top; width:15%; padding: 1em;')
:done()
:tag( 'td' )
:tag('p')
:wikitext( args.enemies )
:done()
:attr('style', 'max-width:85%; width:auto; padding-left: 1em; padding-right: 2em;')
:done()
:done()
end
table:done()
return tostring( table )
end
 

Latest revision as of 15:04, 18 November 2024

Module documentation
This documentation is transcluded from Module:QuestDetails/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:QuestDetails/doc. [edit]
Module:QuestDetails's function details is invoked by Template:QuestDetails.
Module:QuestDetails requires Module:Mw.

local p = {}

function p.details(frame)
	local args = frame:getParent().args
	local mw = require('mw')
	
	if args.start_point then
        mw.smw.set({
            ["start_point"] = args.start_point,
        })
    end
    if args.requirements then
        mw.smw.set({
            ["requirements"] = '\n'..args.requirements,
        })
    end
    if args.recommended then
        mw.smw.set({
            ["recommended"] = '\n'..args.recommended,
        })
    end
    if args.enemies then
        mw.smw.set({
            ["enemies"] = args.enemies,
        })
    end
    
    local requirements;
    if (args.requirements) then
    	requirements = args.requirements
    else
    	requirements = 'None'
    end
	
	local table = mw.html.create( 'table' )
	table
	     :attr( 'class', 'wikitable plainlinks' )
	     :attr( 'cellspacing', '3' )
	     :tag( 'tr' )
		     :tag( 'td' )
		    	:tag( 'b' )
		    		:wikitext('Start Point')
		    	:done()
			 :attr('style', 'vertical-align:top; width:15%; padding: 1em;')
			:done()
			:tag( 'td' )
		    	:tag('p')
		    		:wikitext( args['start_point'] )
		    	:done()
			:attr('style', 'max-width:85%; width:auto; padding-left: 1em; padding-right: 2em;')
			:done()
	     :done()
	     
	     :tag( 'tr' )
		     :tag( 'td' )
		    	:tag( 'b' )
		    		:wikitext('Requirements')
		    	:done()
			 :attr('style', 'vertical-align:top; width:15%; padding: 1em;')
			:done()
			:tag( 'td' )
		    	:tag('div')
		    	:addClass('lighttable checklist')
        		:newline()
        		:wikitext(requirements)
			:attr('style', 'max-width:85%; width:auto; padding: 0.3em;')
			:done()
	     :done()
	     
	     if (args.recommended) then
	     	table
		     	:tag( 'tr' )
			     :tag( 'td' )
			    	:tag( 'b' )
			    		:wikitext('Recommended')
			    	:done()
				 :attr('style', 'vertical-align:top; width:15%; padding: 1em;')
				:done()
				:tag( 'td' )
			    	:tag('div')
	        		:newline()
	        		:wikitext( args.recommended )
				:attr('style', 'max-width:85%; width:auto; padding-left: 1em; padding-right: 2em;')
				:done()
		     :done()
	     end
	     
	     if (args.enemies) then
	     	table
		     	:tag( 'tr' )
			     :tag( 'td' )
			    	:tag( 'b' )
			    		:wikitext('Enemies')
			    	:done()
				 :attr('style', 'vertical-align:top; width:15%; padding: 1em;')
				:done()
				:tag( 'td' )
			    	:tag('p')
			    		:wikitext( args.enemies )
			    	:done()
				:attr('style', 'max-width:85%; width:auto; padding-left: 1em; padding-right: 2em;')
				:done()
		     :done()
	     end
	     
	table:done()
	     
	return tostring( table )
end

return p