Module:ResourceStack
From Corsair Cove Official Wiki
This module combines several resource displays visually into a stack order.
It uses data from Module:ResourceData.
--[[
https://wiki.hoodedhorse.com/Corsair_Cove/Module:ResourceStack
Processes all arguments as resource names with their assigned quantity. Uses an internal lookup table to retrieve their icons. Resources must be spelled correctly and with correct capitalization to match their article name, because the name will be used as the link.
Special arguments `size` and `show_names` are used to specify the size of all icons, from standard `xs` (default) to `xl`, and a default of true or `show_names=false` to show just the icons without the resource names.
Test in the debug console, then copy and paste the output to your user page:
=p.main({args={Planks="20", ["Stone Blocks"]="30"}})
--]]
local ResourceStack = {}
local ARG_SIZE = "size"
local ARG_SHOW_NAMES = "show_names"
local ARG_SHOW_NAMES_DISABLE_FLAG = "false"
local ICON_PLACEHOLDER_FILENAME = "T_Button_SelectionBorder_Default.png"
local icons = {
["barrel"] = "T_ICO_resource_Barrel.png",
["birds"] = "lT_ICO_iresource_bird.png",
["black powder"] = "T_ICO_resource_blackPowder.png",
["booze"] = "T_ICO_resource_DefaultAle.png",
["boots"] = "T_ICO_resource_Boots.png",
["cannonball"] = "T_ICO_resource_CannonballMetall.png",
["cassava bread"] = "T_ICO_resource_CassavaBread.png",
["cassava roots"] = "T_ICO_resource_cassavaRoot.png",
["cast iron"] = "T_ICO_cast_iron.png",
["charcoal"] = "T_ICO_Charburner.png",
["cochineal"] = "T_ICO_resource_Cochineal.png",
["colour pigment"] = "T_ICO_resource_ColorPigment.png",
["copper"] = "T_ICO_resource_copperBars.png",
["copper lamp"] = "T_ICO_resource_CopperLamp.png",
["copper ore"] = "T_ICO_resource_copper.png",
["eggs"] = "T_ICO_resource_egg.png",
["eyepatch"] = "T_ICO_resource_EyePatch.png",
["fabric"] = "T_ICO_resource_Canvas2.png",
["fancy clothing"] = "T_ICO_resource_Garments.png",
["fibre"] = "T_ICO_Fibres.png",
["figurehead"] = "T_ICO_Figurehead.png",
["fish"] = "T_ICO_resource_Fish.png",
["fittings"] = "T_ICO_resource_Fittings.png",
["fresh water"] = "T_ICO_resource_FreshWater.png",
["grain"] = "T_ICO_resource_Grain.png",
["guano"] = "T_ICO_resource_guano.png",
["hard tack"] = "T_ICO_resource_HardTack.png",
["hardwood"] = "T_ICO_resource_Hardwood.png",
["herbs"] = "T_ICO_resource_herbs.png",
["iron ore"] = "T_ICO_resource_ironOre.png",
["jewellery"] = "T_ICO_resource_Jewelry.png",
["jolly roger"] = "T_ICO_resource_JollyRoger.png",
["lead"] = "T_ICO_resource_Lead.png",
["lead ore"] = "T_ICO_resource_LeadOre.png",
["leather"] = "T_ICO_resource_Leather.png",
["lens"] = "T_ICO_resource_Lens.png",
["lime"] = "T_ICO_resource_limestone.png",
["medicine"] = "T_ICO_resource_medicine.png",
["naval gun"] = "T_ICO_resource_navalCannon.png",
["pearl"] = "T_ICO_resource_Pearl.png",
["pig"] = "T_ICO_resource_pig.png",
["pineapple"] = "T_ICO_resource_pineapple.png",
["pistols"] = "T_ICO_resource_Handgun04.png",
["pitch"] = "T_ICO_resource_Pitch.png",
["planks"] = "T_ICO_resource_plank.png",
["prosthesis"] = "T_ICO_resource_Prosthetics.png",
["roast bird"] = "T_ICO_resource_RoastBird.png",
["rope"] = "T_ICO_resource_rope.png",
["rum"] = "T_ICO_resource_Rum.png",
["sabres"] = "T_ICO_resource_cutlass.png",
["sails"] = "T_ICO_resource_Sails.png",
["salt"] = "T_ICO_resource_salt.png",
["seashells"] = "lT_ICO_iresource_seashell.png",
["shot"] = "T_ICO_resource_Shot.png",
["silver"] = "T_ICO_resource_silverBullion.png",
["silver lining"] = "T_ICO_resource_SilverDeco.png",
["slops"] = "T_ICO_resource_Slops.png",
["spyglass"] = "T_ICO_resource_Telescope.png",
["steel"] = "T_ICO_resource_Steel.png",
["steel chain"] = "T_ICO_resource_SteelChain.png",
["stew"] = "T_ICO_resource_DefaultStew.png",
["stone"] = "T_ICO_resource_Stone.png",
["stone blocks"] = "T_ICO_resource_stoneBlocks.png",
["sugar cane"] = "T_ICO_resource_sugarCane.png",
["tabby"] = "T_ICO_resource_tabbyConcrete.png",
["tar"] = "T_ICO_resource_Tar.png",
["tattoo ink"] = "T_ICO_resource_TattooInk.png",
["tobacco"] = "T_ICO_resource_tabacco.png",
["tools"] = "T_ICO_resource_tools.png",
["turtle soup"] = "T_ICO_resource_turtleSoup.png",
["turtles"] = "lT_ICO_iresource_turtule.png",
["whale blubber"] = "T_ICO_resource_WhaleBlubber.png",
["whale oil"] = "T_ICO_resource_WhaleOil.png",
["wine"] = "T_ICO_resource_wine.png",
["wooden awl"] = "T_ICO_resource_WoodenAwl.png",
}
local sizes = {
["xs"] = "x16px",
["sm"] = "x32px",
["md"] = "x64px",
["lg"] = "x96px",
["xl"] = "x128px",
}
function ResourceStack.main(frame)
local size = sizes[frame.args[ARG_SIZE]] or sizes.xs
local showNames = frame.args[ARG_SHOW_NAMES] ~= ARG_SHOW_NAMES_DISABLE_FLAG
local numberStyle = "style=\"text-align: right;\""
local rows = {}
for name, quantity in pairs(frame.args) do
if name ~= ARG_SIZE and name ~= ARG_SHOW_NAMES then
local resource = mw.ustring.lower(name)
local filename = icons[resource] or ICON_PLACEHOLDER_FILENAME
local row = "|-\n|" .. numberStyle .. "| " .. quantity .. " || [[File:" .. filename .. "|" .. size .. "px|link=" .. name .. "|" .. name .. "]]"
if showNames then
row = row .. " || [[" .. name .. "]]"
end
table.insert(rows, row)
end
end
return "{|\n" .. table.concat(rows, "\n") .. "\n|}"
end
return ResourceStack


