Module:ModNames

From ATLauncher Wiki
Jump to: navigation, search
Lua Logo.svg This is the Lua module for Template:ModLink. Below is the documentation for that template.

Returns a link to a given mod. If no link is found for the mod, it will return the given string.

Usage

This template is mainly used in infobox templates, it should not be used directly on articles.

Example

{{ModLink|IC2}} gives IndustrialCraft2

See Module:ModNames page for full list abbreviation of mod names.


local p = {}

local g = require("Module:Common")

-- Table that maps page names to sequences of abbreviations.
-- The (normalized) page name is automatically included as an abbr.
-- All other abbrs must be normalized, i. e. all lowercase and alphanumeric characters only.
p.name2abbrs = {
	["AcademyCraft"] = {"ac"};
	["Actually Additions"] = {"actadd"};
	["Additional BuildCraft Objects"] = {"abo"};
	["Advanced Generators"] = {"advgenerators"};
	["Advanced Genetics"] = {"ag"};
	["Advanced Machines"] = {"am"};
	["Advanced Power Management"] = {"apm"};
	["Advanced Rocketry"] = {"ar"};
	["Advanced Solar Panels"] = {"asp", "advancedsolarpanel"};
	["Adventure Backpack"] = {"ab"};
	["Adventurer's Amulets"] = {"aa"};
	["AE2 Stuff"] = {ae2s};
	["AgriCraft"] = {};
	["Alchemistry"] = {"alc", "alchemistry"};
	["Amun-Ra"] = {"a-r", "amunra"};
	["Another One Bites the Dust"] = {"aobd"};
	["AppleMilkTea2"] = {"amt2"};
	["Applied Energistics"] = {"ae", "appeng"};
	["Applied Energistics 2"] = {"ae2"};
	["Arcane Engineering"] = {};
	["Archimedes' Ships"] = {"archship", "archimedes"};
	["Aroma1997's Dimensional World"] = {"aroma1997sdimension"};
	["Ars Magica 2"] = {"am2"};
	["Assembly Line"] = {"al"};
	["ATLauncher"] = {"atl"};
	["Atomic Science"] = {"as"};
	["Automagy 1"] = {"automagy", "a1"};
	["Automagy 2"] = {"a2"};
	["Avaritia"] = {};
	["Avaritiaddons"] = {};
	["Backpacks"] = {"bp"};
	["Balkon's WeaponMod"] = {"weaponmod"};
	["B.A.S.E"] = {"base"};
	["Basic Components"] = {};
	["Baubley Heart Canisters"] = {"bhc"};
	["Better Furnaces"] = {"FLabsBF"};
	["BetterChests"] = {};
	["BetterStorage"] = {};
	["BiblioCraft"] = {};
	["Big Reactors"] = {"br"};
	["Biomes O' Plenty"] = {"bop"};
	["Blank Planet"] = {};
	["Blood Arsenal"] = {};
	["Blood Magic"] = {"bm", "awwayoftime"};
	["Botania"] = {};
	["Botanical Addons"] = {"shadowfox_botany"};
	["Brandon's Core"] = {};
	["BuildCraft"] = {"bc", "bc3", "buildcraft3", "buildcraft4", "buildcraft5", "buildcraft6"};
	["BuildCraft Additions"] = {"bcadditions"};
	["BuildCraft Tools"] = {"bct"};
	["Calculator"] = {};
	["Carpenter's Blocks"] = {"cb"};
	["ChaosCraft"] = {"chaos"};
	["ChickenChunks"] = {"chc", "chchunks"};
	["ChargePads"] = {"cp"};
	["Charlotte's Utilities"] = {};
	["Chisel"] = {};
	["CodeChickenCore"] = {"ccc", "chickenbonescore"};
	["CodeChickenLib"] = {"ccl"};
	["CompactSolars"] = {"cs", "compsol", "compactsolararrays"};
	["Compact Machines"] = {"cm", "cmh"};
	["Compact Windmills"] = {"cw", "cwm"};
	["ComputerCraft"] = {"cc"};
	["Cooking for Blockheads"] = {"cookingbook"};
	["Craft Arcanum 1"] = {"craftarcanum"};
    ["Cyclic"] = {"cyclicmagic", "cycl"};
	["DartCraft"] = {"dc"};
	["Decocraft"] = {"props"};
	["Dense Ores"] = {"do"};
	["Dimensional Anchors"] = {"da"};
	["Dimensional Doors"] = {"dd", "dimdoors"};
	["Divine RPG"] = {"drpg", "divinerpg"};
	["Draconic Evolution"] = {"de"};
	["Electrical Age"] = {"eln", "ea"};
	["ElectriCraft"] = {};
	["Electro-Magic Tools"] = {"emt"};
	["Emasher Resource"] = {"emasher"};
	["Enchanting Plus"] = {"eplus"};
	["EnderIO"] = {"eio"};
	["EnderStorage"] = {"es", "enderchest", "enderchests"};
	["EnderTech"] = {};
	["Ender Prospecting"] = {};
	["Ender Zoo"] = {"ez"};
	["Engineer's Toolbox"] = {"etb", "eng_toolbox"};
	["EnhancedPortals 2"] = {"ep2", "enhancedportals"};
	["Environmental Tech"] = {};
	["Equivalent Exchange"] = {"ee"};
	["Equivalent Exchange 2"] = {"ee2"};
	["Equivalent Exchange 3"] = {"ee3"};
	["Essential Thaumaturgy"] = {"essenthaum"};
	["EssentialCraft III"] = {"essentialcraft"};
	["EvilCraft"] = {"evc", "evilcraft"};
	["Expanded Redstone"] = {"er"};
	["Ex Astris"] = {"exaliquo"};
	["Ex Compressum"] = {"exc"};
	["Ex Nihilo"] = {"en", "exn"};
	["Ex Nihilo Adscensio"] = {"ena", "exna"};
	["Extra Bees"] = {"eb"};
	["Extra Cells"] = {"ec"};
	["Extra Cells 2"] = {"ec2"};
	["Extra Trees"] = {"et"};
	["ExtrabiomesXL"] = {"ebxl", "extrabiomes"};
	["Extra Peripherals"] = {};
	["Extra Planets"] = {"ep"};
	["Extra Utilities"] = {"eu", "extrautils"};
	["Extra Utilities 2"] = {"eu2", "extrautils2"};
	["Factorization"] = {"fz"};
	["Factory Tech"] = {"ft"};
	["Feed The Beast"] = {"ftb"};
	["Flan's Mod"] = {};
	["Food Plus"] = {};
	["Forbidden Magic"] = {};
	["Forestry"] = {"fy"};
	["Forge IRC"] = {};
	["Forge Mod Loader"] = {"fml", "forgeml"};
	["FullThrottle Alchemist"] = {"fta", "projectalchemy"};
	["Gadomancy"] = {};
	["Galacticraft"] = {"gc", "galacticraftcore", "galacticraftmars", "galacticraftplanets"};
	["Garden of Glass"] = {"gardenglass", "gog", "gardenofglass"};
	["Garden Stuff"] = {"gardencore", "gardencontainers", "gardentrees"};
	["GasCraft"] = {};
	["Gendustry"] = {};
	["Gravitation Suite"] = {"gs", "gravisuite", "graviationsuite" --[[sic]]};
	["Gravity Gun"] = {"gravigun"};
	["GregTech 4"] = {"gt", "gt4", "gregtech_addon"};
	["GregTech 5"] = {"gt5"};
	["GregTech 6"] = {"gt6"};
	["GregTech Community Edition"] = {"gtce"};
	["Hammerz"] = {};
	["Hardcore Ender Expansion"] = {"hee"};
	["Hardcore Questing Mode"] = {"hqm", "hardcorequest", "hardcorequesting", "hardcorequestingmod"};
	["Heavy-Duty Plate Blocks"] = {"hdpb"};
	["Hydraulicraft"] = {"hydc"};
	["Ice and Fire"] = {"iaf"};
	["IndustrialCraft 2"] = {"ic", "ic2", "industrialcraft"};
	["IndustrialCraft 2 Experimental"] = {"ic2x", "ic2exp"};
	["ICBM"] = {};
	["Immersive Engineering"] = {"ie"};
	["Inventory Tweaks"] = {"invtweaks"};
	["Iron Chests"] = {"ich", "ironchests", "ironchest"};
	["Iron Shulker Boxes"] = {"isb", "ironshulker", "ironshulkerbox"};
	["JABBA"] = {};
	["LibVulpes"] = {};
	["Logistics Pipes"] = {"lp", "logipipes", "logisticpipes"};
	["Loot Bags"] = {};
	["Magic Bees"] = {"mb", "thaumicbees"};
	["Magic Cookies"] = {"magiccookie"};
	["Magical Crops"] = {};
	["Magical Decorations"] = {"mdeco"};
	["Magneticraft"] = {};
	["Mariculture"] = {};
	["Mekanism"] = {"mk", "mekanismgenerators", "mekanismtools"};
	["Mob Grinding Utils"] = {"mgu"};
	["Metallurgy"] = {"me"};
	["Metallurgy 3"] = {"me3"};
	["MFFS Calclavia"] = {};
	["Millénaire"] = {"mil", "millenaire"};
	["Minecraft"] = {"mc", "vanilla", "vanillaminecraft"};
	["Minecraft Forge"] = {"forge", "mcforge"};
	["MineChem"] = {"mch"};
	["MineFactory Reloaded"] = {"mfr", "minefactory"};
	["Misc Peripherals"] = {};
	["Mod Coder Pack"] = {"mcp", "minecraftcoderpack"};
	["Modular Force Field System"] = {"mffs"};
	["Modular Powersuits"] = {"mps", "powersuits"};
	["More Planets"] ={"mp"};
	["More Charcoal"] ={"morecharcoal"};
	["MPSaddons"] = {"mpsa"};
	["Mystcraft"] = {"myst"};
	["Mystical Agriculture"] ={"mysticalagriculture", "mac"};
	["Natura"] = {};
	["Nether Ores"] = {"no"};
	["Not Enough Items"] = {"nei"};
	["Nuclear Control"] = {"nc"};
	["Nuclear Control 2"] = {"nc2"};
	["ObsidiPlates"] = {"obsidianplates", "obsidian pressure plates"};
	["OmniTools"] = {};
	["One More"] = {"om"};
	["OpenBlocks"] = {"ob"};
	["OpenComputers"] = {"oc", "opencomp"};
	["Pam's BoneCraft"] = {"pbc", "bonecraft"};
	["Pam's DesertCraft"] = {"pdc", "desertcraft"};
	["Pam's HarvestCraft"] = {"pam", "ph", "hc", "phc", "harvestcraft"};
	["Pam's Temperate Plants"] = {"ptp", "temperateplants"};
	["Pam's Weee! Flowers"] = {"pamflowers", "pwf", "weeeflowers"};
	["Petroleum Generator (Mod)"] = {"petrogen", "petroleumgenerator"};
	["Pistronics"] = {"pistronics2"};
	["Plugins for Forestry"] = {"pff"};
	["PneumaticCraft"] = {"pneumaticraft"};
	["Portal Gun (Mod)"] = {"pg", "pgm", "portalgun", "portalgunmod"};
	["Power Converters"] = {"pc"};
	["Practicalities"] = {"jotatospracticalities"};
	["Primitive Mobs"] = {};
	["Professor Flaxbeard's Wondrous Steam Power Mod"] = {"fsp", "fsm", "wsp", "pfwsp", "pfwspm", "steampower", "flaxbeardsteampower", "flaxbeardssteampower", "steamcraft"};
	["Progressive Automation"] = {};
	["Project Red"] = {"pr", "projred"};
	["Project Zulu"] = {"pz"};
	["qCraft"] = {"qc"};
	["Quark"] = {};
	["QuarryPlus"] = {"qp"};
	["Railcraft"] = {"rc"};
	["Random Things"] = {};
	["ReactorCraft"] = {};
	["RedLogic"] = {};
	["RedPower 2"] = {"rp", "rp2", "redpower"};
	["Redstone Arsenal"] = {"ra"};
	["Rei's Minimap"] = {"reimap", "reiminimap"};
	["RFTools"] = {"rft"};
	["Risugami's ModLoader"] = {"rml", "modloader"};
	["RotaryCraft"] = {"rotc"};
	["Secret Rooms"] = {"sr", "secretroomsmod"};
	["Simply Jetpacks"] = {"sj"};
	["Sky Resources 1"] = {"skyresources"};
	["Sky Resources 2"] = {"sr2"};
	["SlabCraft"] = {"slabcraftmod"};
	["Solar Expansion"] = {"se"};
	["Solar Flux"] = {};
	["Soul Shards"] = {"ss"};
	["Speedy Hoppers"] = {"speedyhoppers"};
	["Steve's Carts 2"] = {"sc2", "stevescarts"};
	["Steve's Factory Manager"] = {"sfm"};
	["Stone Crafting Table"] = {"sct"};
	["Storage Drawers"] = {};
	["Super Circuit Maker"] = {"scm", "rscircuits"};
	["Super Solar Panels"] = {"ssp", "supersolarpanel"};
	["Sync"] = {};
	["Tainted Magic"] = {};
	["Technomancy"] = {"tmy", "technom"};
	["Tech Reborn"] = {"tr"};
	["Thaumaturgical Knowledge"] = {"benway_knowledge"};
	["Thaumcraft"] = {"tc"};
	["Thaumcraft 3"] = {"tc3"};
	["Thaumcraft 4"] = {"tc4", "tc41", "thaumcraft41"};
	["Thaumcraft 5"] = {"tc5"};
	["Thaumcraft 6"] = {"tc6"};
	["Thaumcraft Gates"] = {};
	["Thaumic Additions"] = {};
	["Thaumic Additions: Reconstructed"] = {"tar"};
	["Thaumic Bases 1"] = {"thaumicbases"};
	["Thaumic Bases 2"] = {};
	["Thaumic Energistics"] = {};
	["Thaumic Expansion"] = {};
	["Thaumic Exploration"] = {};
	["Thaumic Horizons"] = {};
	["Thaumic Infusion"] = {};
	["Thaumic Revelations"] = {"trevelations"};
	["Thaumic Restoration"] = {"trestoration"};
	["Thaumic Upholstry"] = {"tu"};
	["Thaumic Warden"] = {"twarden"};
	["ThaumOres"] = {};
	["Thermal Dynamics"] = {"td"};
	["Thermal Expansion"] = {"te", "te2", "te3", "te4"};
	["Thermal Foundation"] = {"tf"};
	["Thermal Innovation"] = {"thermalinnovation"};
	["The Void"] = {"The Void", "tv"};
	["Tinkers' Construct"] = {"tic", "tcon", "tconstruct", "tinkerersconstruct"};
	["Tinkers' Mechworks"] = {"tim", "tmech", "tmechworks"};
	["Tinkers' Steelworks"] = {"tis", "tsteel", "tsteelworks"};
	["TrainCraft"] = {};
	["Traveller's Gear"] = {};
	["Tropicraft"] = {};
	["Thaumic Tinkerer 1"] = {"tt", "thaumictinkerer", "tt1"};
	["Thaumic Tinkerer 2"] = {"tt2"};
	["Thaumic Tinkerer 3"] = {"tt3"};
	["Thaumic Tinkerer 5"] = {"tt5"};
	["The Elysium"] = {"elysium"};
	["TubeStuff"] = {"ts"};
	["Twilight Forest"] = {"twifor"};
	["Up And Down And All Around"] = {"uadaaa"};
	["Warp Theory"] = {};
	["Wireless Crafting Terminal"] = {"wct"};
	["Wireless Redstone ChickenBones Edition"] = {"wrcbe", "wirelessredstone", "wirelessredstonecbe"};
	["Witchery"] = {"witch"};
	["Witching Gadgets"] = {};
	["Xeno's Reliquary"] = {"reliquary", "xreliquary", "xr"};
	["XyCraft"] = {"xy"};
	["Ye Gamol Chattels"] = {"ygc", "yegc", "yegch"};
	["Zollern Galaxy"] = {"zg"};
}

-- Table that maps page names to display titles
p.name2display = {
	["Advanced Rocketry (Library)"] = "Advanced Rocketry";
	["Bookshelf (Library)"] = "Bookshelf";
	["Bookshelf (Mod)"] = "Bookshelf";
	["IndustrialCraft 2"] = "IndustrialCraft<sup>2</sup>";
	["IndustrialCraft 2 Experimental"] = "IndustrialCraft<sup>2</sup> Experimental";
	["Petroleum Generator (Mod)"] = "Petroleum Generator";
	["Portal Gun (Mod)"] = "Portal Gun";
	["Stone Crafting Table (Mod)"] = "Stone Crafting Table";
}

p.abbr2name = {} -- Table that maps lowercase abbreviations to page names

-- Table of misc. suffixes to strip from item/block names
-- Format is similar to that of abbr2name for easier use
p.miscSuffixes = {
	["block"] = "Block";
	["mob"] = "Mob";
	["mod"] = "Mod";
	["modpack"] = "Modpack";
	["item"] = "Item";
}

-- Remove any wikilink or template call from s, returning only the link target or template name.
function p.unlink(s)
	return (s:match("[%[%{]+([^%|%]%}]+)[^%]%}]*[%]%}]+") or s)
end

-- Strip common wiki markup characters from s. This implicitly calls p.unlink(s).
function p.unmarkup(s)
	return (p.unlink(s):gsub("[%|%[%]%{%}]+", ""):gsub("''+", ""))
end

-- Convert s to lowercase and strip all non-alphanumeric characters. This implicitly calls p.unmarkup(s).
function p.normalize(s)
	return (p.unmarkup(s):lower():gsub("[^%w]+", ""))
end

-- Populate p.abbr2name
for name, abbrs in pairs(p.name2abbrs) do
	for i, abbr in ipairs(abbrs) do
		p.abbr2name[p.normalize(abbr)] = name
	end
	-- Include normalized name as an abbr
	p.abbr2name[p.normalize(name)] = name
end

-- Expand abbr to a page name. If abbr is not recognized, return p.unmarkup(abbr).
function p.getPagename(abbr)
	return p.abbr2name[p.normalize(abbr)] or p.unmarkup(abbr)
end

-- Expand abbr to a display name. If no special display name is known, return p.getPagename(abbr).
function p.getDisplayname(abbr)
	local pn = p.getPagename(abbr)
	return p.name2display[pn] or pn
end

-- Expand abbr into a full wikilink, with proper target and display title.
-- If p.normalize(abbr) is either "unknown" or "various", no linking or expansion is performed.
-- If smwprop is given, make the wikilink a SMW property assignment, with smwprop being the property name.
function p.getWikilink(abbr, smwprop)
	local labbr = p.normalize(abbr)
	if labbr == "unknown" or labbr == "various" then
		return abbr
	else
		if g.isGiven(smwprop) then
			smwprop = smwprop .. "::"
		else
			smwprop = ""
		end
		
		return "[[" .. smwprop .. p.getPagename(abbr) .. "|" .. p.getDisplayname(abbr) .. "]]"
	end
end

-- Remove known disambig suffixes from the end of label, such as (Block) or (BuildCraft).
-- Unknown suffixes are left in place - for example "Machine Frame (Basic)" is not modified.
function p.stripSuffix(label)
	-- Pattern matching all parenthesized suffixes (e.g. "(BuildCraft)", "(Block)", etc.)
	local suffix = label:match("%(.+%)$")
	if suffix ~= nil then
		local trimmed = suffix:sub(2, -2):lower()
		
		if p.abbr2name[trimmed] or p.miscSuffixes[trimmed] then
			return label:sub(1, -(#suffix + 2))
		end
	end
	
	return label
end

-- MediaWiki wrappers around the above functions
function p.mwGetPagename(frame) return p.getPagename(frame.args[1]) end
function p.mwGetDisplayname(frame) return p.getDisplayname(frame.args[1]) end
function p.mwGetWikilink(frame) return p.getWikilink(frame.args[1], frame.args[2]) end
function p.mwStripSuffix(frame) return p.stripSuffix(frame.args[1]) end

return p