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('WARFRAME Wiki:L10n/general.json', 'WARFRAME Wiki:L10n/meta.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]]")
			:caption('UpdateInfoboxData', '[[Module:Resources/data|📝 %s]]', 'update-infobox-data')
		: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', '[[Rarity|%s]]', resourceData.Rarity and resourceData.Rarity..'[[Category:'..resourceData.Rarity..' Resources]]' or '', 'rarity')
			:row('Amount', '%s', resourceData.Amount and resourceData.Amount[1]..'-'..resourceData.Amount[2]..'x', 'drop-amount')
			: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('SortingPriority', '%s', resourceData.SortingPriority and resourceData.SortingPriority, 'sorting-priority')
			:row('Introduced', '%s', resourceData.Introduced and '{{ver|'..resourceData.Introduced..'}}[[Category:Update '..resourceData.Introduced:sub(1, (string.find(resourceData.Introduced, '%.') or 0) - 1)..']]', 'introduced')
		: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()
	:group():header('%s', 'official-drop-tables')
		:caption('official-drop-tables', 'https://www.warframe.com/droptables', 'official-drop-tables')
	:done()
	
	return frame:preprocess(tostring(Infobox))
end
}
Advertisement