Module:ResourceData

From Against the Storm Official Wiki
Revision as of 05:05, 2 February 2023 by Aeredor (talk | contribs) (reordered)

Documentation for this module may be created at Module:ResourceData/doc

-------------------------------------------------------------------------------
-- Lua storage table for looking up image files based on in-game names.
--
-- The table contains some deconfliction, but only for spaces and just a few
-- cases of singular and plural versions.
-- Use in-game names for things, and help keep this table updated as the game
-- is updated.
--
-- Using the table requires a locally defined lookup function that performs 
-- a string.lower on the argument so that the lookup table can accept any case 
-- and still function properly. Otherwise, we would need the table to define
-- Berries = "Berries.png" and berries = "Berries.png" which would suck.
-------------------------------------------------------------------------------


-- for returning when REQUIRE'd by other Lua modules.
local IconFilenames = {}



-------------------------------------------------------------------------------
-- Main data table, with string keys and string values.
-- Some of these are defined inline with string.lower to make the key easier
-- to spell and read correctly.
-------------------------------------------------------------------------------

local tableStrStrFilenames = {
    -- Raw Food
	["berries"] = "Berries.png",
	["eggs"] = "Eggs.png",
	["insects"] = "Insects.png",
	["meat"] = "Meat.png",
	["mushrooms"] = "Mushrooms.png",
	["roots"] = "Roots.png",
	["vegetables"] = "Vegetables.png",
	-- Complex Food
	["biscuits"] = "Biscuits.png",
	["jerky"] = "Jerky.png",
	[string.lower("PickledGoods")] = "PickledGoods.png",
	["pickled goods"] = "PickledGoods.png",
	["pie"] = "Pie.png",
	["skewers"] = "Skewers.png",
	-- Building Materials
	["bricks"] = "Bricks.png",
	["fabric"] = "Fabric.png",
	["planks"] = "Planks.png",
	["parts"] = "Parts.png",
	[string.lower("WildfireEssence")] = "Wildfire Essence.png",
	["wildfire essence"] = "Wildfire Essence.png",
	-- Consumable Items
	["coats"] = "Coats.png",
	["ale"] = "Ale.png",
	["cosmetics"] = "Cosmetics.png",
	["incense"] = "Incense.png",
	["scrolls"] = "Scrolls.png",
	[string.lower("TrainingGear")] = "TrainingGear.png",
	["training gear"] = "TrainingGear.png",
	["wine"] = "Wine.png",
	-- Crafting Materials
	["clay"] = "Clay.png",
	[string.lower("CopperOre")] = "CopperOre.png",
	["copper ore"] = "CopperOre.png",
	[string.lower("CrystalizedDew")] = "CrystalizedDew.png",
	["crystalized dew"] = "CrystalizedDew.png",
	["grain"] = "Grain.png",
	["herbs"] = "Herbs.png",
	["leather"] = "Leather.png",
	["plantfiber"] = "PlantFiber.png",
	["plant fiber"] = "PlantFiber.png",
	["reeds"] = "Reeds.png",
	["reed"] = "Reeds.png",
	["resin"] = "Resin.png",
	["sparkdew"] = "Sparkdew.png",
	["stone"] = "Stone.png",
	-- Refined Crafting Materials
	["barrels"] = "Barrels.png",
	["barrel"] = "Barrels.png",
	["copperbar"] = "CopperBar.png",
	["copper bar"] = "CopperBar.png",
	["flour"] = "Flour.png",
	["pigment"] = "Pigment.png",
	["pigments"] = "Pigment.png",
	["pottery"] = "Pottery.png",
	["waterskins"] = "Waterskins.png",
	["waterskin"] = "Waterskins.png",
	-- Trade Goods
	["buildingmaterials"] = "BuildingMaterials.png",
	["packofbuildingmaterials"] = "BuildingMaterials.png",
	["crops"] = "Crops.png",
	["packofcrops"] = "Crops.png",
	["luxurygoods"] = "Luxury.png",
	["packofluxurygoods"] = "Luxury.png",
	["provisions"] = "Provisions.png",
	["packofprovisions"] = "Provisions.png",
	["tradegoods"] = "TradeGoods.png",
	["packoftradegoods"] = "TradeGoods.png",
	["amber"] = "Amber.png",
	[string.lower("AncientTablet")] = "AncientTablet.png",
	["ancient tablet"] = "AncientTablet.png",
	["foodstockpiles"] = "Icon MetaResource FoodStockpiles.png",
	["food stockpiles"] = "Icon MetaResource FoodStockpiles.png",
	["metafood"] = "Icon MetaResource FoodStockpiles.png",
	["machinery"] = "Icon MetaResource Machinery.png",
	["metamachinery"] = "Icon MetaResource Machinery.png",
	["artifact"] = "Icon MetaResource Artifact.png",
	["artifacts"] = "Icon MetaResource Artifact.png",
	[string.lower("MetaArtifact")] = "Icon MetaResource Artifact.png",
	-- Fuel & Exploration
	["coal"] = "Coal.png",
	["oil"] = "Oil.png",
	["seamarrow"] = "SeaMarrow.png",
	["sea marrow"] = "SeaMarrow.png",
	["wood"] = "Wood.png",
	["simpletools"] = "SimpleTools.png",
	["simple tools"] = "SimpleTools.png",
	["infusedtools"] = "InfusedTools.png",
	["infused tools"] = "InfusedTools.png",
	["purgingfire"] = "PurgingFire.png",
	["purging fire"] = "PurgingFire.png"
}



-------------------------------------------------------------------------------
-- Main lookup function
-- Accepts the name of an icon, as it appears in the game, and returns the
-- filename associated with that in-game item, resource, building, etc.
-------------------------------------------------------------------------------

function IconFilenames.getIconFilename(strIconName)

	-- Convert the key to lower case for case-insensitive lookups
    local strLowercaseIconName = string.lower(strIconName)
	
	-- Get it from the big table below and return it.
    return tableStrStrFilenames[strLowercaseIconName]
end



-------------------------------------------------------------------------------
-- Return when required into another Module.
-------------------------------------------------------------------------------
return IconFilenames