Module:Item uses: Difference between revisions

From The Cycle: Frontier Wiki
mNo edit summary
mNo edit summary
Line 23: Line 23:
local printData = useData['printing']
local printData = useData['printing']


local hasOutput = false;
local hasOutput = false
-- missions
-- missions
for index, value in pairs(missionData) do
for index, value in pairs(missionData) do
Line 65: Line 65:
if hasOutput == false then
if hasOutput == false then
return frame:preprocess("This item has no uses in any [[Missions]], [[Jobs]], [[Personal Quarters]], [[The Forge|Forge Recipes]], or [[Printing|Printing Recipes]]. It is purely for selling to a [[Factions|Faction]] vendor.")
return "This item has no uses in any [[Missions]], [[Jobs]], [[Personal Quarters]], [[The Forge|Forge Recipes]], or [[Printing|Printing Recipes]]. It is purely for selling to a [[Factions|Faction]] vendor."
end
end
return frame:preprocess(wikitext)
if hasOutput then
end
return frame:preprocess(wikitext)
 
end
local function isEmpty(t)
    for _,_ in pairs(t) do
        return false
    end
    return true
end
end


return p
return p

Revision as of 19:22, 1 June 2023

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:


Uses for Portable Lab
Type Quantity
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 }
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 = '{| class="wikitable" \n|+ Uses for ' .. p.data['inGameName'] .. '\n! Type !! Quantity\n'
	
	local missionData = useData['missions']
	local jobData = useData['jobs']
	local quarterData = useData['quarters']
	local forgeData = useData['forge']
	local printData = useData['printing']

	local hasOutput = false
	-- missions
	for index, value in pairs(missionData) do
		hasOutput = true
		local name = mw.text.split(value['inGameName'], " Part ", true)
		wikitext = wikitext .. '\n|-\n|[[' .. name[1] .. '#Part_' .. name[2] .. '-0|' .. value['inGameName'] .. ']] ||' .. value['amount'].. '<br>'
	end
	
	-- jobs
	for index, value in pairs(jobData) do
		hasOutput = true
		wikitext = wikitext .. '\n|-\n|[[' .. value['inGameName'] .. ']] ||' .. value['amount']
	end
	
	-- quarters 
	for index, value in pairs(quarterData) do
		hasOutput = true
		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 .. '\n|-\n|[[Personal Quarters#' .. tab .. '|' .. value['inGameName'] .. ']] ||' .. value['amount'] 
	end
	
	-- forge
	for index, value in pairs(forgeData) do
		hasOutput = true
		wikitext = wikitext .. '\n|-|{{Icon|' .. value['inGameName'] .. '}} [[The Forge|' .. value['inGameName'] .. ']] ||' .. value['amount']
	end
	
	-- printing
	for index, value in pairs(printData) do
		hasOutput = true
		wikitext = wikitext .. '\n|-|{{Icon link|' .. value['inGameName'] .. '}} ||' .. value['amount']
	end
	wikitext = wikitext .. '|}'
	
	if hasOutput == false then
		return "This item has no uses in any [[Missions]], [[Jobs]], [[Personal Quarters]], [[The Forge|Forge Recipes]], or [[Printing|Printing Recipes]]. It is purely for selling to a [[Factions|Faction]] vendor."
	end
	
	if hasOutput then
		return frame:preprocess(wikitext)
	end
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.