|
|
(11 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| -------------------------------------------------------------------------------
| | <includeonly>{{#invoke:ResourceLink|main |
| -- Lua storage table for looking up wiki pages, names, and resources
| | |name={{{name|{{{1|}}}}}} |
| -- based on in-game names. All data is in English.
| | |size={{{size|{{{2|{{{1|}}}}}}}}} |
| --
| | |display={{{display|}}} |
| -- The table contains some deconfliction, but only for spaces, apostrophes, and
| | }}</includeonly><noinclude> |
| -- some singular/plural.
| |
| -- 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
| |
| -- both Berries = "Berries" and berries = "Berries" which would multiply our
| |
| -- work.
| |
| -------------------------------------------------------------------------------
| |
|
| |
|
| | {{Documentation}} |
|
| |
|
| -- for returning when REQUIRE'd by other Lua modules.
| | [[Category:Lua-based templates]] |
| local ResourceData = {}
| | [[Category:Link templates]]</noinclude> |
| | |
| | |
| | |
| -------------------------------------------------------------------------------
| |
| -- 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.
| |
| -------------------------------------------------------------------------------
| |
| | |
| -- a design decision of this table is to make the key the same as the page name.
| |
| -- (the lookup methods will automatically make it lowercase.)
| |
| -- that way, whenever .page is referenced, it can be used again to retrieve
| |
| -- the rest of the data.
| |
| local tableStrStrData = {
| |
| | |
| ---------------------------------------
| |
| -- Resources
| |
| ---------------------------------------
| |
| -- Raw Food
| |
| ["berries"] = {iconfile="Berries.png", page="Berries"},
| |
| ["eggs"] = {iconfile="Eggs.png", page="Eggs"},
| |
| ["insects"] = {iconfile="Insects.png", page="Insects"},
| |
| ["meat"] = {iconfile="Meat.png", page="Meat"},
| |
| ["mushrooms"] = {iconfile="Mushrooms.png", page="Mushrooms"},
| |
| ["roots"] = {iconfile="Roots.png", page="Roots"},
| |
| ["vegetables"] = {iconfile="Vegetables.png", page="Vegetables"},
| |
| -- Complex Food
| |
| ["biscuits"] = {iconfile="Biscuits.png", page="Biscuits"},
| |
| ["jerky"] = {iconfile="Jerky.png", page="Jerky"},
| |
| ["pickled goods"] = {iconfile="PickledGoods.png", page="Pickled Goods"},
| |
| ["pie"] = {iconfile="Pie.png", page="Pie"},
| |
| ["skewers"] = {iconfile="Skewers.png", page="Skewers"},
| |
| -- Building Materials
| |
| ["bricks"] = {iconfile="Bricks.png", page="Bricks"},
| |
| ["fabric"] = {iconfile="Fabric.png", page="Fabric"},
| |
| ["planks"] = {iconfile="Planks.png", page="Planks"},
| |
| ["parts"] = {iconfile="Parts.png", page="Parts"},
| |
| ["wildfire essence"] = {iconfile="Wildfire Essence.png", page="Wildfire Essence"},
| |
| -- Consumable Items
| |
| ["coats"] = {iconfile="Coats.png", page="Coats"},
| |
| ["ale"] = {iconfile="Ale.png", page="Ale"},
| |
| ["cosmetics"] = {iconfile="Cosmetics.png", page="Cosmetics"},
| |
| ["incense"] = {iconfile="Incense.png", page="Incense"},
| |
| ["scrolls"] = {iconfile="Scrolls.png", page="Scrolls"},
| |
| ["training gear"] = {iconfile="TrainingGear.png", page="Training Gear"},
| |
| ["wine"] = {iconfile="Wine.png", page="Wine"},
| |
| -- Crafting Materials
| |
| ["clay"] = {iconfile="Clay.png", page="Clay"},
| |
| ["copper ore"] = {iconfile="CopperOre.png", page="Copper Ore"},
| |
| ["crystalized dew"] = {iconfile="CrystalizedDew.png", page="Crystalized Dew"},
| |
| ["grain"] = {iconfile="Grain.png", page="Grain"},
| |
| ["herbs"] = {iconfile="Herbs.png", page="Herbs"},
| |
| ["leather"] = {iconfile="Leather.png", page="Leather"},
| |
| ["plant fiber"] = {iconfile="PlantFiber.png", page="Plant Fiber"},
| |
| ["reeds"] = {iconfile="Reeds.png", page="Reeds"},
| |
| ["resin"] = {iconfile="Resin.png", page="Resin"},
| |
| ["sparkdew"] = {iconfile="Sparkdew.png", page="Sparkdew"},
| |
| ["stone"] = {iconfile="Stone.png", page="Stone"},
| |
| -- Refined Crafting Materials
| |
| ["barrels"] = {iconfile="Barrels.png", page="Barrels"},
| |
| ["copper bars"] = {iconfile="CopperBar.png", page="Copper Bars"},
| |
| ["flour"] = {iconfile="Flour.png", page="Flour"},
| |
| ["pigment"] = {iconfile="Pigment.png", page="Pigment"},
| |
| ["pottery"] = {iconfile="Pottery.png", page="Pottery"},
| |
| ["waterskins"] = {iconfile="Waterskins.png", page="Waterskins"},
| |
| -- Trade Goods
| |
| ["amber"] = {iconfile="Amber.png", page="Amber"},
| |
| ["ancient tablet"] = {iconfile="AncientTablet.png", page="Ancient Tablet"},
| |
| ["pack of building materials"] = {iconfile="BuildingMaterials.png", page="Pack of Building Materials"},
| |
| ["pack of crops"] = {iconfile="Crops.png", page="Pack of Crops"},
| |
| ["pack of luxury goods"] = {iconfile="Luxury.png", page="Pack of Luxury Goods"},
| |
| ["pack of provisions"] = {iconfile="Provisions.png", page="Pack of Provisions"},
| |
| ["pack of trade goods"] = {iconfile="TradeGoods.png", page="Pack of Trade Goods"},
| |
| -- Meta resources
| |
| ["artifacts"] = {iconfile="Icon MetaResource Artifact.png", page="Artifacts"},
| |
| ["food stockpiles"] = {iconfile="Icon MetaResource FoodStockpiles.png", page="Food Stockpiles"},
| |
| ["machinery"] = {iconfile="Icon MetaResource Machinery.png", page="Machinery"},
| |
| -- Fuel & Exploration
| |
| ["coal"] = {iconfile="Coal.png", page="Coal"},
| |
| ["oil"] = {iconfile="Oil.png", page="Oil"},
| |
| ["sea marrow"] = {iconfile="SeaMarrow.png", page="Sea Marrow"},
| |
| ["wood"] = {iconfile="Wood.png", page="Wood"},
| |
| ["simple tools"] = {iconfile="SimpleTools.png", page="Simple Tools"},
| |
| ["infused tools"] = {iconfile="InfusedTools.png", page="Infused Tools"},
| |
| ["purging fire"] = {iconfile="PurgingFire.png", page="Purging Fire"},
| |
| }
| |
| | |
| | |
| | |
| -------------------------------------------------------------------------------
| |
| -- Main lookup functions
| |
| -- Accepts the in-game name and returns the name of the page on the wiki
| |
| -- associated with that in-game item, resource, building, etc.
| |
| -------------------------------------------------------------------------------
| |
| | |
| | |
| | |
| -- returns the whole data table for the specified key
| |
| -- need to run normalize function first
| |
| function ResourceData.getData(strArg)
| |
| | |
| -- normalize input
| |
| local strArg = ResourceData.normalizeName(strArg)
| |
|
| |
| -- Get it from the big table below and return it.
| |
| return tableStrStrData[strArg]
| |
| end
| |
| | |
| | |
| | |
| -- simpler version if all that's needed is the iconfile.
| |
| -- error handling by the calling module is required.
| |
| function ResourceData.getIconFilename(strArg)
| |
| | |
| local data = getData(strArg)
| |
|
| |
| -- if this particular data block doesn't have a iconfile, this will return nil
| |
| -- therefore, error handling will be necessary
| |
| return data.iconfile or nil
| |
| end
| |
| | |
| | |
| | |
| -- simpler version if all that's needed is the page name.
| |
| -- error handling by the calling module is required.
| |
| function ResourceData.getPagename(strArg)
| |
| | |
| local data = getData(strArg)
| |
|
| |
| -- if this particular data block doesn't have a page name, this will return nil
| |
| -- therefore, error handling will be necessary
| |
| return data.page or nil
| |
| end
| |
| | |
| | |
| | |
| -- simpler version if all that's needed is the description.
| |
| -- error handling by the calling module is required.
| |
| function ResourceData.getDescription(strArg)
| |
| | |
| local data = getData(strArg)
| |
|
| |
| -- if this particular data block doesn't have a description, this will return nil
| |
| -- therefore, error handling will be necessary
| |
| return data.description or nil
| |
| end
| |
| | |
| | |
| | |
| -------------------------------------------------------------------------------
| |
| -- Helper functions
| |
| -------------------------------------------------------------------------------
| |
| | |
| | |
| | |
| -- Normalize the argument to the standard in-game name, and the one that
| |
| -- is used as the key in the big lookup table.
| |
| --
| |
| -- This function will also make the argument lowercase to reduce the need
| |
| -- to specify more possible alternatives to normalize.
| |
| function ResourceData.normalizeName(strArg)
| |
|
| |
| strArg = string.lower(strArg)
| |
|
| |
| -- no other functions need this lookup table, so it's defined locally
| |
| -- to this function
| |
| local tableStrStrAlternatives = {
| |
|
| |
| ---------------------------------------
| |
| -- Resources
| |
| ---------------------------------------
| |
| -- Raw Food
| |
| ["berry"] = "berries",
| |
| ["egg"] = "eggs",
| |
| ["insect"] = "insects",
| |
| ["meats"] = "meat",
| |
| ["mushroom"] = "mushrooms",
| |
| ["root"] = "roots",
| |
| ["vegetable"] = "vegetables",
| |
| --Complex Food
| |
| ["biscuit"] = "biscuits",
| |
| ["pickledgoods"] = "pickled goods",
| |
| ["pickledgood"] = "pickled goods",
| |
| ["pickled good"] = "pickled goods",
| |
| ["pies"] = "pie",
| |
| ["skewer"] = "skewers",
| |
| -- Building Materials
| |
| ["brick"] = "bricks",
| |
| ["fabrics"] = "fabric",
| |
| ["plank"] = "planks",
| |
| ["part"] = "parts",
| |
| ["wildfireessence"] = "wildfire essence",
| |
| ["wild fire essence"] = "wildfire essence",
| |
| ["wildfireessences"] = "wildfire essence",
| |
| ["wild fire essences"] = "wildfire essence",
| |
| -- Consumable items
| |
| ["coat"] = "coats",
| |
| ["ales"] = "ale",
| |
| ["cosmetic"] = "cosmetics",
| |
| ["incenses"] = "incense",
| |
| ["insense"] = "incense",
| |
| ["scroll"] = "scrolls",
| |
| ["traininggear"] = "training gear",
| |
| ["traininggears"] = "training gear",
| |
| ["training gears"] = "training gear",
| |
| ["wines"] = "wine",
| |
| -- Crafting materials
| |
| ["clays"] = "clay",
| |
| ["copperore"] = "copper ore",
| |
| ["copperores"] = "copper ore",
| |
| ["copper ores"] = "copper ore",
| |
| ["crystalizeddew"] = "crystalized dew",
| |
| ["crystalizeddews"] = "crystalized dew",
| |
| ["crystallizeddew"] = "crystalized dew",
| |
| ["crystallizeddews"] = "crystalized dew",
| |
| ["crystalized dews"] = "crystalized dew",
| |
| ["crystallized dew"] = "crystalized dew",
| |
| ["crystallized dews"] = "crystalized dew",
| |
| ["grains"] = "grain",
| |
| ["herb"] = "herbs",
| |
| ["leathers"] = "leather",
| |
| ["flax"] = "plant fiber",
| |
| ["plantfiber"] = "plant fiber",
| |
| ["plantfibers"] = "plant fiber",
| |
| ["plant fibers"] = "plant fiber",
| |
| ["reed"] = "reeds",
| |
| ["spark dew"] = "sparkdew",
| |
| ["stones"] = "stone",
| |
| -- Refined crafting materials
| |
| ["barrel"] = "barrels",
| |
| ["barrell"] = "barrels",
| |
| ["barrells"] = "barrels",
| |
| ["copperbar"] = "copper bars",
| |
| ["copperbars"] = "copper bars",
| |
| ["copper bar"] = "copper bars",
| |
| ["flours"] = "flour",
| |
| ["pigments"] = "pigment",
| |
| ["waterskin"] = "waterskins",
| |
| ["water skin"] = "waterskins",
| |
| ["water skins"] = "waterskins",
| |
| -- Trade goods
| |
| ["ambers"] = "amber",
| |
| ["coin"] = "amber",
| |
| ["tablet"] = "ancient tablet",
| |
| ["tablets"] = "ancient tablet",
| |
| ["ancienttablet"] = "ancient tablet",
| |
| ["ancienttablets"] = "ancient tablet",
| |
| ["ancient tablets"] = "ancient tablet",
| |
| ["buildingmaterial"] = "pack of building materials",
| |
| ["buildingmaterials"] = "pack of building materials",
| |
| ["building material"] = "pack of building materials",
| |
| ["building materials"] = "pack of building materials",
| |
| ["packofbuildingmaterial"] = "pack of building materials",
| |
| ["packofbuildingmaterials"] = "pack of building materials",
| |
| ["pack of building materials"] = "pack of building materials",
| |
| ["packsofbuildingmaterial"] = "pack of building materials",
| |
| ["packsofbuildingmaterials"] = "pack of building materials",
| |
| ["packs of building materials"] = "pack of building materials",
| |
| ["crop"] = "pack of crops",
| |
| ["crops"] = "pack of crops",
| |
| ["packofcrop"] = "pack of crops",
| |
| ["packofcrops"] = "pack of crops",
| |
| ["pack of crop"] = "pack of crops",
| |
| ["packsofcrop"] = "pack of crops",
| |
| ["packsofcrops"] = "pack of crops",
| |
| ["packs of crop"] = "pack of crops",
| |
| ["luxury"] = "pack of luxury goods",
| |
| ["luxuries"] = "pack of luxury goods",
| |
| ["luxurygood"] = "pack of luxury goods",
| |
| ["luxurygoods"] = "pack of luxury goods",
| |
| ["luxury good"] = "pack of luxury goods",
| |
| ["luxury goods"] = "pack of luxury goods",
| |
| ["packofluxuries"] = "pack of luxury goods",
| |
| ["packofluxurygood"] = "pack of luxury goods",
| |
| ["packofluxurygoods"] = "pack of luxury goods",
| |
| ["pack of luxury good"] = "pack of luxury goods",
| |
| ["packsofluxuries"] = "pack of luxury goods",
| |
| ["packsofluxurygood"] = "pack of luxury goods",
| |
| ["packsofluxurygoods"] = "pack of luxury goods",
| |
| ["packs of luxury good"] = "pack of luxury goods",
| |
| ["provision"] = "pack of provisions",
| |
| ["provisions"] = "pack of provisions",
| |
| ["packofprovision"] = "pack of provisions",
| |
| ["packofprovisions"] = "pack of provisions",
| |
| ["pack of provision"] = "pack of provisions",
| |
| ["packsofprovision"] = "pack of provisions",
| |
| ["packsofprovisions"] = "pack of provisions",
| |
| ["packs of provision"] = "pack of provisions",
| |
| ["tradegood"] = "pack of trade goods",
| |
| ["tradegoods"] = "pack of trade goods",
| |
| ["trade good"] = "pack of trade goods",
| |
| ["trade goods"] = "pack of trade goods",
| |
| ["packoftradegood"] = "pack of trade goods",
| |
| ["packoftradegoods"] = "pack of trade goods",
| |
| ["pack of trade good"] = "pack of trade goods",
| |
| ["packsoftradegood"] = "pack of trade goods",
| |
| ["packsoftradegoods"] = "pack of trade goods",
| |
| ["packs of trade good"] = "pack of trade goods",
| |
| -- Meta resources
| |
| ["artifact"] = "artifacts",
| |
| ["metaartifact"] = "artifacts",
| |
| ["metaartifacts"] = "artifacts",
| |
| ["meta artifact"] = "artifacts",
| |
| ["meta artifacts"] = "artifacts",
| |
| ["food"] = "food stockpiles",
| |
| ["foods"] = "food stockpiles",
| |
| ["metafood"] = "food stockpiles",
| |
| ["metafoods"] = "food stockpiles",
| |
| ["meta food"] = "food stockpiles",
| |
| ["meta foods"] = "food stockpiles",
| |
| ["foodstockpile"] = "food stockpiles",
| |
| ["foodstockpiles"] = "food stockpiles",
| |
| ["food stockpile"] = "food stockpiles",
| |
| ["meta foodstockpile"] = "food stockpiles",
| |
| ["meta foodstockpiles"] = "food stockpiles",
| |
| ["meta food stockpile"] = "food stockpiles",
| |
| ["meta food stockpiles"] = "food stockpiles",
| |
| ["machinary"] = "machinery",
| |
| ["metamachinery"] = "machinery",
| |
| ["meta machinery"] = "machinery",
| |
| -- Fuel & Exploration
| |
| ["coals"] = "coal",
| |
| ["oils"] = "oil",
| |
| ["seamarrow"] = "sea marrow",
| |
| ["seamarrows"] = "sea marrow",
| |
| ["sea marrows"] = "sea marrow",
| |
| ["woods"] = "wood",
| |
| ["simpletool"] = "simple tools",
| |
| ["simpletools"] = "simple tools",
| |
| ["simple tool"] = "simple tools",
| |
| ["infusedtool"] = "infused tools",
| |
| ["infusedtools"] = "infused tools",
| |
| ["infused tool"] = "infused tools",
| |
| ["purgingfire"] = "purging fire",
| |
| ["purgingfires"] = "purging fire",
| |
|
| |
| } -- the end of the huge tableStrStrAlternatives
| |
|
| |
| -- if nothing is found, the result of the lookup will be nil, so
| |
| -- just return whatever was passed in as the argument (lowercase)
| |
| -- we can assume that the input argument is fine or does not exist
| |
| return tableStrStrAlternatives[strArg] or strArg
| |
| end
| |
| | |
| | |
| | |
| -------------------------------------------------------------------------------
| |
| -- Return when required into another Module.
| |
| -------------------------------------------------------------------------------
| |
| return ResourceData
| |
Overview
Creates a link to the article for a resource (or good).
Template:rl is a shortcut to this template. You can use {{rl}}
instead of {{Resource link}}
with the same parameters.
Use good judgment when writing paragraphs that feature a lot of resource links. The first mention should probably be done with this template. But you may find that paragraphs densely mentioning resources become harder not easier to read due to the icons and color fluctuations. After the first mention of the resource, it might be better for subsequent references to be in plain text or with this template but without an icon.
Parameters
Resource
The name of the resource (or good) is the only required parameter. Use the name as it appears in-game, including spaces. A missing or mispelled name will result in an error.
If you do not wish to write the code name=
, you may skip that, but you must specify the name of the resource before any other parameters.
Parameter |
Type |
Description
|
name |
string |
The name of the resource, as it appears in the game.
|
Output overrides
All of these parameters are optional and change how the link is formatted.
Parameter |
Type |
Description
|
size |
string |
The size of the icon to display. Choose one of the following:
none
small
medium
large
huge
The default for resources is small , suitable for paragraphs.
|
display |
string |
if you include display=notext only the icon will be rendered. There are currently no other options for this parameter.
|
Resource links that are written into paragraphs should use the small icon, which is the default, or no icon. The small icon size conforms to the standard line height of text on the wiki and will not disrupt the flow of text.
Note that adding "s" after the template call no longer includes the "s" in the link as it used to.
Examples
Basic usage
{{Resource link|Biscuits}}
Makes a link to the Biscuits article with a small icon suitable for use in-line in paragraphs like this that discuss villagers and their needs for yummy food. Subsequent mention of Biscuits in the same paragraph can omit the link to avoid adding unnecessary color to paragraphs.
{{Resource link|Biscuits|medium}}
Yields an icon that's slightly larger for improved recognition. Suitable for tables that list lots of resources where layout provides some space for icons:
Biscuits
{{Resource link|name=Biscuits|large}}
Yields a large icon for good recognition for use in tables with space that allows it:
Biscuits
{{Resource link|Biscuits|size=huge}}
Yields the largest icon, which is great for headlining tables featuring this resource:
Biscuits
Other examples
{{Resource link|Biscuits|size=none}}
Alternatively, paragraphs can include even simpler links like Biscuits that display no icon to improve the flow of the paragraph at the cost of a slight reduction in recognition since the resource icons are so ubiquitous in the game. The highlighting of the link is still sufficient to draw the reader's attention. No icon is advised for every link to a resource after its first (where an icon is appropriate) within each paragraph.
Using no icon is also great for lists:
{{Resource link|Biscuits|size=large|display=notext}}
Yields an icon with no label. This is useful in tables where the meanings are obvious or provided another way.
{{Resource link|Jerky|size=gigantic}}
Specifying an icon size that is not recognized does not return an error. Instead, it defaults to the small icon:
Jerky
Errors
The following are error messages generated by calling the template incorrectly.
{{Resource link}}
With no arguments: Lua error in Module:ResourceLink at line 64: You must specify a resource. Please see the template documentation for how to use the parameters.
{{Resource link|Potatoes}}
Naming a resource that doesn't exist in the game: Lua error in Module:ResourceLink at line 41: No resource found with name: Potatoes. Please see the template documentation for how to use the parameters.
{{Resource link|huge|Jerky}}
The same goes for swapping the order of the parameters so that the resource is not first: Lua error in Module:ResourceLink at line 41: No resource found with name: huge. Please see the template documentation for how to use the parameters.