WARFRAME Wiki

Read about the future of the Fandom platform and the WARFRAME wiki! Any feedback would be appreciated! User blog:Cephalon Scientia/2022 Fandom Community Connect. - 06:11, 6 June 2022 (UTC)

READ MORE

WARFRAME Wiki
Advertisement
WARFRAME Wiki

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

--	<nowiki>
local Table = require([[Module:Table]])
local DropTable = require([[Module:DropTables]])
local Vendor = require([[Module:Vendors]])
local InfoboxBuilder = require([[Module:InfoboxBuilder]])
local ResourceData = mw.loadData([[Module:Resources/data]])
local DropData = mw.loadData([[Module:DropTables/data]])

local function override(arg)
	return arg and arg..'[[Category:InfoboxOverride]]'
end

return {
buildInfobox = function(frame)
	local args = frame.args;
	local name = mw.text.decode(args['Name'])
	local resourceData = ResourceData.Resources[name]
	if resourceData == nil then
		error('buildInfobox(frame): "'..name..'" does not exist in [[Module:Resources/data]]')
	end
	
	local Infobox = InfoboxBuilder('MediaWiki:Custom-General/i18n.json')
		:tag('title')
			:tag('default')
				:tag('b'):wikitext(name..'[[Category:Resources]]'):done()
			:done()
		:done()
		:tag('image'):attr('source', 'Image')
			:tag('default'):wikitext((resourceData.ContainerImage ~= nil and 
					('<gallery>%s|Pickup\n%s|Deposit</gallery>'):format(resourceData.Image, resourceData.ContainerImage) or 
					resourceData.Image) or 'Panel.png'):done()
		:done()
		:group()
			:caption('Tradable', resourceData.Tradable and "[[File:TradableIcon.png|x32px|class=icon dark-invert]] [[Trading|{{text|green|Tradeable}}]][[Category:Tradeable Resources]]" or "[[Trading|{{text|red|Untradeable}}]] [[Category:Untradeable Resources]]")
		:done()
		
		:group():header('Description')
			:caption('Description', resourceData.Description)
		:done()

		:group():header('%s', 'general-information')
			:row('Type', '%s', (resourceData.Type ~= 'Resource') and resourceData.Type..'[[Category:'..resourceData.Type..' Resources]]' or resourceData.Type, 'type')
			:row('Rarity', '%s', resourceData.Rarity and resourceData.Rarity..'[[Category:'..resourceData.Rarity..' Resources]]' or '', 'rarity')
			:row('Helminth', '[[Helminth#Secretions|Helminth Secretions]]', resourceData.HelminthCategory and resourceData.HelminthCategory..' ('..resourceData.HelminthCost..')[[Category:Helminth Resources]]' or '')
			:row('SellPrice', '%s', '[[File:Credits64.png|x20px|link=Credits]] '..(resourceData.SellPrice and resourceData.SellPrice or 'Cannot Sell'), 'sell-price')
			:row('Introduced', '%s', resourceData.Introduced and '{{ver|'..resourceData.Introduced..'}}[[Category:Update '..resourceData.Introduced:sub(1, (string.find(resourceData.Introduced, '%.') or 0) - 1)..']]', 'introduced')
		:done()
		--[[
		:group():header('%s', 'internal-name')
			:caption('InternalName', resourceData.InternalName and '<code>'..resourceData.InternalName..'</code>' or 'N/A')
		:done()
		--]]
	local missionStr, enemyStr, containerStr = DropTable._buildDropTableSourceStrings(name)
	
	Infobox:group():header('%s', 'drop-table-sources')
		:tag('data'):attr('source', 'Drops')
			:tag('default')
				:tag('div'):addClass('tabber-borderless')
					:wikitext(('<tabber>%s%s%s</tabber>'):format(
					(missionStr ~= '') and '|-|Missions='..missionStr..'\n' or '',
					(enemyStr ~= '') and '|-|Enemies='..enemyStr..'\n' or '',
					(containerStr ~= '') and '|-|Containers='..containerStr..'\n' or ''
				)):done()
			:done()
		:done()
	:done()
	
	local vendorStr = Vendor._buildVendorSourceStrings(name)
	
	Infobox:group():header('%s', 'vendor-sources')
		:tag('data'):attr('source', 'Offerings')
			:tag('default')
				:tag('div'):addClass('tabber-borderless')
					:wikitext(('<tabber>%s</tabber>'):format(
					(vendorStr ~= '') and '|-|Vendors='..vendorStr..'\n' or ''
				)):done()
			:done()
		:done()
	:done()
	
	return frame:preprocess(tostring(Infobox))
end
}
Advertisement