Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:InfoboxWorkstation

From Vault Hunters Official Wiki
Revision as of 02:39, 7 July 2025 by Mnooseman (talk | contribs) (Created page with "local p = {} local function getImage(frame, baseName) local png = 'File:' .. baseName .. '.png' local gif = 'File:' .. baseName .. '.gif' local existsPng = frame:preprocess('{{#ifexist:' .. png .. '|yes|no}}') if existsPng == 'yes' then return png end local existsGif = frame:preprocess('{{#ifexist:' .. gif .. '|yes|no}}') if existsGif == 'yes' then return gif end return nil end function p.main(frame) local args = frame:getParent().args local title = mw.titl...")
(diff) ← Older revision | Latest revision (diff) | Newer revision β†’ (diff)

Documentation for this module may be created at Module:InfoboxWorkstation/doc

local p = {}

local function getImage(frame, baseName)
	local png = 'File:' .. baseName .. '.png'
	local gif = 'File:' .. baseName .. '.gif'

	local existsPng = frame:preprocess('{{#ifexist:' .. png .. '|yes|no}}')
	if existsPng == 'yes' then return png end

	local existsGif = frame:preprocess('{{#ifexist:' .. gif .. '|yes|no}}')
	if existsGif == 'yes' then return gif end

	return nil
end

function p.main(frame)
	local args = frame:getParent().args
	local title = mw.title.getCurrentTitle().text

	local name = args.name or title
	local baseImageName = args.image or ('Invicon_' .. title)
	local imageFile = getImage(frame, baseImageName)
	local questbook = args.questbook or 'Unknown'
	local version = args.version or 'Unknown'

	local html = mw.html.create('table')
	html
		:addClass('infobox')
		:addClass('infobox-workstation')
		:css('width', '300px')
		:tag('tr')
			:tag('th')
				:attr('colspan', '2')
				:css('text-align', 'center')
				:wikitext(name)
			:done()
		:done()
		:tag('tr')
			:tag('td')
				:attr('colspan', '2')
				:css('text-align', 'center')
				:wikitext(imageFile and ('[[' .. imageFile .. '|center|frameless|128px]]') or 'No image available')
			:done()
		:done()
		:tag('tr')
			:tag('td'):wikitext('Inventory Slot'):done()
			:tag('td'):wikitext(frame:expandTemplate{title = 'Inventory slot', args = {title}}):done()
		:done()
		:tag('tr')
			:tag('td'):wikitext('Quest Book'):done()
			:tag('td'):wikitext(questbook):done()
		:done()
		:tag('tr')
			:tag('td'):wikitext('Added in'):done()
			:tag('td'):wikitext(version):done()
		:done()

	return tostring(html)
end

return p