Module:QuestDetails: Difference between revisions

(Created page with "local p = {} local infobox = require('Module:Infobox') local parse = require('Module:Param Parse') function p.details(frame) local _args = frame:getParent().args local ret = infobox.new(_args) ret:defineParams { { name = 'start_point' }, { name = 'requirements' }, } ret:create() ret:cleanParams() ret:addClass('questdetails') ret:attr { cellspacing = '3' } local auto_width = { ["max-width"] = "85%", ["width"] =...")
 
mNo edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}

local infobox = require('Module:Infobox')
local parse = require('Module:Param Parse')


function p.details(frame)
function p.details(frame)
local _args = frame:getParent().args
local args = frame:getParent().args
local ret = infobox.new(_args)
local mw = require('mw')

if args.start_point then
ret:defineParams {
{ name = 'start_point' },
mw.smw.set({
["start_point"] = tostring(args.start_point),
{ name = 'requirements' },
}
})
end
if args.requirements then
mw.smw.set({
["requirements"] = tostring(args.requirements),
})
end
if args.recommended then
mw.smw.set({
["recommended"] = tostring(args.recommended),
})
end
if args.enemies then
mw.smw.set({
["enemies"] = tostring(args.enemies),
})
end
local requirements;
ret:create()
if (args.requirements) then
ret:cleanParams()
requirements = args.requirements

else
ret:addClass('questdetails')
ret:attr { cellspacing = '3' }
requirements = 'None'
end

local auto_width = { ["max-width"] = "85%", ["width"] = "auto" }
local table = mw.html.create( 'table' )
ret:addRow {
table
{ tag = 'th', class = "questdetails-header", content = 'Start point' },
:attr( 'class', 'wikitable plainlinks' )
{ tag = 'argd', class = "questdetails-info", content=infobox.param('name'), css = auto_width }
:attr( 'cellspacing', '3' )
}
:tag( 'tr' )

ret:addRow {
:tag( 'td' )
:tag( 'b' )
{ tag = 'th', class = "questdetails-header", content = 'Requirements' },
:wikitext('Start Point')
{ tag = 'td', class = "questdetails-info", content=infobox.param('requirements'), colspan = 2 }
}
:done()
:attr('style', 'vertical-align:top; width:15%; padding: 0 1em;')

:done()
return ret
: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: 0 1em;')
:done()
:tag( 'td' )
:tag('p')
:wikitext( requirements )
:done()
:attr('style', 'max-width:85%; width:auto; padding-left: 1em; padding-right: 2em;')
:done()
:done()
if (args.recommended) then
table
:tag( 'tr' )
:tag( 'td' )
:tag( 'b' )
:wikitext('Recommended')
:done()
:attr('style', 'vertical-align:top; width:15%; padding: 0 1em;')
:done()
:tag( 'td' )
:tag('p')
:wikitext( args.recommended )
:done()
: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: 0 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
end



Latest revision as of 22:43, 17 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"] = tostring(args.start_point),
        })
    end
    if args.requirements then
        mw.smw.set({
            ["requirements"] = tostring(args.requirements),
        })
    end
    if args.recommended then
        mw.smw.set({
            ["recommended"] = tostring(args.recommended),
        })
    end
    if args.enemies then
        mw.smw.set({
            ["enemies"] = tostring(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: 0 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: 0 1em;')
			:done()
			:tag( 'td' )
		    	:tag('p')
		    		:wikitext( requirements )
		    	:done()
			:attr('style', 'max-width:85%; width:auto; padding-left: 1em; padding-right: 2em;')
			:done()
	     :done()
	     
	     if (args.recommended) then
	     	table
		     	:tag( 'tr' )
			     :tag( 'td' )
			    	:tag( 'b' )
			    		:wikitext('Recommended')
			    	:done()
				 :attr('style', 'vertical-align:top; width:15%; padding: 0 1em;')
				:done()
				:tag( 'td' )
			    	:tag('p')
			    		:wikitext( args.recommended )
			    	:done()
				: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: 0 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