Module:Item uses

From The Cycle: Frontier Wiki
Revision as of 18:39, 1 June 2023 by VeryGreatFrog (talk | contribs) (Add support for personal quarters tab fragment links)

To use this Module, use the wrapper template Template:Item uses.

Usage

Pass the item you want the list for as the first argument, like so:

 {{Item uses|Portable Lab}} 

Which gives:

Research Costs Part 1 1
Combat Ready Part 2 1
Everything is Crystals Part 2 1
Increase Safe Pocket Size 7.1 1
K-Marks Generator Cap 6.3 2
Supply Crate Level 7.2 1


local p = {} --p stands for package
p.loadedData = mw.loadJsonData( "Module:Item infobox/itemData.json" )
local args = mw.getCurrentFrame().args

-- find the item data for our input arg
for k, v in pairs(p.loadedData) do
    if args[1] == v["inGameName"] then
    	if args[2] == nil or args[2] == '' then
        	p.data = p.loadedData[k]
        	break
    	end
    end
end

function p.main( frame )
	local useData = p.data['uses']
	local wikitext = ''
	-- missions
	local missionData = useData['missions']
	for index, value in pairs(missionData) do
		local name = mw.text.split(value['inGameName'], " Part ", true)
		wikitext = wikitext .. '[[' .. name[1] .. '#Part_' .. name[2] .. '-0|' .. value['inGameName'] .. ']] ' .. value['amount'] .. '<br>'
	end
	
	-- jobs
	local jobData = useData['jobs']
	for index, value in pairs(jobData) do
		wikitext = wikitext .. '[[' .. value['inGameName'] .. ']] ' .. value['amount'] .. '<br>'
	end
	
	-- quarters 
	local quarterData = useData['quarters']
	for index, value in pairs(quarterData) do
		local tab = 'Quarters-0'
		if string.find(index, 'generate') or string.find(index, 'passive') then
			tab = 'Generator-0'
		elseif string.find(index, 'increase_bag') or string.find(index, 'stash') then
			tab = 'Inventory-0'
		elseif string.find(index, 'reduce_pq') then
			tab = 'Player_Quarter_Upgrade_Time-0'
		end
		wikitext = wikitext .. '[[Personal Quarters#' .. tab .. '|' .. value['inGameName'] .. ']] ' .. value['amount'] .. '<br>'
	end
	
	-- forge
	local forgeData = useData['forge']
	for index, value in pairs(forgeData) do
		wikitext = wikitext .. '{{Icon|' .. value['inGameName'] .. '}} [[The Forge|' .. value['inGameName'] .. ']] ' .. value['amount'] .. '<br>'
	end
	
	-- printing
	local printData = useData['printing']
	for index, value in pairs(printData) do
		wikitext = wikitext .. '{{Icon link|' .. value['inGameName'] .. '}} ' .. value['amount'] .. '<br>'
	end
	return frame:preprocess(wikitext)
end
return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.