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:
Portable Lab has one or multiple uses in The Cycle: Frontier. To complete all missions and quarter upgrades, this item is needed 7 times.
Type | Quantity |
---|---|
Missions | |
Research Costs Part 1 | 1 |
Combat Ready Part 2 | 1 |
Everything is Crystals Part 2 | 1 |
Personal Quarters | |
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 = '{| 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
local useOnceCount = 0;
-- missions
local hasDoneMissionOutput = false
for index, value in pairs(missionData) do
if not hasDoneMissionOutput then
wikitext = wikitext .. '\n|-\n! colspan="2" | [[Missions]]'
hasDoneMissionOutput = true
end
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>'
useOnceCount = useOnceCount + value['amount']
end
-- jobs
local hasDoneJobsOutput = false
-- these jobs must have the (Job) text appended to the link as they are otherwise the same as another page
local jobTextList = {"NEW-Hard-ICA-Gather-2", "NEW-Medium-KOR-Mine-1", "NEW-Medium-KOR-Mine-3", "NEW-Medium-KOR-Meteor-1", "NEW-Hard-KOR-Meteor-1", "NEW-Hard-KOR-Mine-3", "NEW-Hard-KOR-Hunt-1", "NEW-Easy-Osiris-Flora-1", "NEW-Medium-Osiris-Gather-5", "NEW-Medium-Osiris-Flora-2"}
for index, value in pairs(jobData) do
if not hasDoneJobsOutput then
wikitext = wikitext .. '\n|-\n! colspan="2" | [[Jobs]]'
hasDoneJobsOutput = true
end
local name = value['inGameName']
-- set name in some edge cases
if p.contains(jobTextList, index) then
name = name .. ' (Job)'
elseif index == 'NEW-Hard-KOR-Gather-4' then
name = 'Energy Crisis (Korolev)'
elseif index == 'NEW-Hard-ICA-Mine-2' then
name = 'Energy Crisis (ICA)'
end
hasOutput = true
wikitext = wikitext .. '\n|-\n|[[' .. name .. ']] ||' .. value['amount']
end
-- quarters
local hasDoneQuartersOutput = false
for index, value in pairs(quarterData) do
if not hasDoneQuartersOutput then
wikitext = wikitext .. '\n|-\n! colspan="2" | [[Personal Quarters]]'
hasDoneQuartersOutput = true
end
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']
useOnceCount = useOnceCount + value['amount']
end
-- forge
local hasDoneForgeOutput = false
for index, value in pairs(forgeData) do
if not hasDoneForgeOutput then
wikitext = wikitext .. '\n|-\n! colspan="2" | [[The Forge|Forge Recipes]]'
hasDoneForgeOutput = true
end
hasOutput = true
wikitext = wikitext .. '\n|-\n|{{Icon|' .. value['inGameName'] .. '}} [[The Forge#Recipes|' .. value['inGameName'] .. ']] ||' .. value['amount']
end
-- printing
local hasDonePrintingOutput = false
for index, value in pairs(printData) do
if not hasDonePrintingOutput then
wikitext = wikitext .. '\n|-\n! colspan="2" | [[Printing|Printing Recipes]]'
hasDonePrintingOutput = true
end
hasOutput = true
wikitext = wikitext .. '\n|-\n|{{Icon link|' .. value['inGameName'] .. '}} ||' .. value['amount']
end
wikitext = wikitext .. '\n|}'
--return mw.dumpObject(forgeData)
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
local textBeforeTable = '{{Icon link|' .. p.data['inGameName'] .. '}} has one or multiple uses in \'\'The Cycle: Frontier\'\'. To complete all [[missions]] and [[Personal Quarters|quarter upgrades]], this item is needed '.. useOnceCount .. ' times.\n'
return frame:preprocess(textBeforeTable .. wikitext)
end
end
function p.contains(list, x)
for _, v in pairs(list) do
if v == x then return true end
end
return false
end
return p