mNo edit summary |
m (Finish output) |
||
Line 7: | Line 7: | ||
if args[1] == v["inGameName"] then | if args[1] == v["inGameName"] then | ||
if args[2] == nil or args[2] == '' then | if args[2] == nil or args[2] == '' then | ||
p.data = p.loadedData[k] | |||
break | |||
end | end | ||
end | end | ||
Line 24: | Line 24: | ||
local hasOutput = false | local hasOutput = false | ||
local useOnceCount = 0; | |||
-- missions | -- missions | ||
local hasDoneMissionOutput = false | |||
for index, value in pairs(missionData) do | for index, value in pairs(missionData) do | ||
if not hasDoneMissionOutput then | |||
wikitext = wikitext .. '\n|-\n! colspan="2" | [[Missions]]' | |||
hasDoneMissionOutput = true | |||
end | |||
hasOutput = true | hasOutput = true | ||
local name = mw.text.split(value['inGameName'], " Part ", 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>' | wikitext = wikitext .. '\n|-\n|[[' .. name[1] .. '#Part_' .. name[2] .. '-0|' .. value['inGameName'] .. ']] ||' .. value['amount'].. '<br>' | ||
useOnceCount = useOnceCount + value['amount'] | |||
end | end | ||
-- jobs | -- jobs | ||
local hasDoneJobsOutput = false | |||
for index, value in pairs(jobData) do | for index, value in pairs(jobData) do | ||
if not hasDoneJobsOutput then | |||
wikitext = wikitext .. '\n|-\n! colspan="2" | [[Jobs]]' | |||
hasDoneJobsOutput = true | |||
end | |||
hasOutput = true | hasOutput = true | ||
wikitext = wikitext .. '\n|-\n|[[' .. value['inGameName'] .. ']] ||' .. value['amount'] | wikitext = wikitext .. '\n|-\n|[[' .. value['inGameName'] .. ']] ||' .. value['amount'] | ||
Line 38: | Line 51: | ||
-- quarters | -- quarters | ||
local hasDoneQuartersOutput = false | |||
for index, value in pairs(quarterData) do | for index, value in pairs(quarterData) do | ||
if not hasDoneQuartersOutput then | |||
wikitext = wikitext .. '\n|-\n! colspan="2" | [[Personal Quarters]]' | |||
hasDoneQuartersOutput = true | |||
end | |||
hasOutput = true | hasOutput = true | ||
local tab = 'Quarters-0' | local tab = 'Quarters-0' | ||
Line 49: | Line 67: | ||
end | end | ||
wikitext = wikitext .. '\n|-\n|[[Personal Quarters#' .. tab .. '|' .. value['inGameName'] .. ']] ||' .. value['amount'] | wikitext = wikitext .. '\n|-\n|[[Personal Quarters#' .. tab .. '|' .. value['inGameName'] .. ']] ||' .. value['amount'] | ||
useOnceCount = useOnceCount + value['amount'] | |||
end | end | ||
-- forge | -- forge | ||
local hasDoneForgeOutput = false | |||
for index, value in pairs(forgeData) do | 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 | hasOutput = true | ||
wikitext = wikitext .. '\n|-|{{Icon|' .. value['inGameName'] .. '}} [[The Forge|' .. value['inGameName'] .. ']] ||' .. value['amount'] | wikitext = wikitext .. '\n|-\n|{{Icon|' .. value['inGameName'] .. '}} [[The Forge|' .. value['inGameName'] .. ']] ||' .. value['amount'] | ||
end | end | ||
-- printing | -- printing | ||
local hasDonePrintingOutput = false | |||
for index, value in pairs(printData) do | 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 | hasOutput = true | ||
wikitext = wikitext .. '\n|-|{{Icon link|' .. value['inGameName'] .. '}} ||' .. value['amount'] | wikitext = wikitext .. '\n|-\n|{{Icon link|' .. value['inGameName'] .. '}} ||' .. value['amount'] | ||
end | end | ||
wikitext = wikitext .. '\n|}' | wikitext = wikitext .. '\n|}' | ||
--return mw.dumpObject(forgeData) | |||
if hasOutput == false then | 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." | 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." | ||
Line 69: | Line 99: | ||
if hasOutput then | if hasOutput then | ||
return frame:preprocess(wikitext) | local textBeforeTable = 'To complete all progression in \'\'The Cycle: Frontier\'\', a total of ' .. useOnceCount .. ' {{Icon link|' .. p.data['inGameName'] .. '}} is needed.\n' | ||
return frame:preprocess(textBeforeTable .. wikitext) | |||
end | end | ||
end | end | ||
return p | return p |
Revision as of 19:56, 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:
To complete all progression in The Cycle: Frontier, a total of 7 Portable Lab is needed.
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
for index, value in pairs(jobData) do
if not hasDoneJobsOutput then
wikitext = wikitext .. '\n|-\n! colspan="2" | [[Jobs]]'
hasDoneJobsOutput = true
end
hasOutput = true
wikitext = wikitext .. '\n|-\n|[[' .. value['inGameName'] .. ']] ||' .. 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|' .. 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 = 'To complete all progression in \'\'The Cycle: Frontier\'\', a total of ' .. useOnceCount .. ' {{Icon link|' .. p.data['inGameName'] .. '}} is needed.\n'
return frame:preprocess(textBeforeTable .. wikitext)
end
end
return p