Module:VanDerProtofsky/ModNames

From ATLauncher Wiki
Jump to: navigation, search

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

p = {}

g = require("Module:Common")

-- Table that maps page names to tables of abbreviations
p.name2abbrs = {
	["Additional BuildCraft Objects"] = {"abo"};
	["Advanced Genetics"] = {"ag"};
	["Advanced Machines"] = {};
	["Advanced Solar Panels"] = {};
	["Applied Energistics"] = {"ae", "appeng"};
	["Archimedes' Ships"] = {"archship", "archimedes", "archimedes ships"};
	["Ars Magica 2"] = {"am2", "arsmagica2"};
	["Assembly Line"] = {};
	["Atomic Science"] = {};
	["Backpacks"] = {};
	["Basic Components"] = {};
	["BetterChests"] = {"better chests"};
	["BetterStorage"] = {"better storage"};
	["BiblioCraft"] = {"biblio craft"};
	["Big Reactors"] = {"br", "bigreactors"};
	["Biomes O' Plenty"] = {"bop", "biomesoplenty", "biomes o plenty"};
	["BuildCraft"] = {"bc", "bc3", "buildcraft", "buildcraft 3", "buildcraft 4"};
	["ChaosCraft"] = {"chaos"};
	["ChickenChunks"] = {"chc", "chchunks"};
	["CodeChickenCore"] = {"ccc", "chickenbones core"};
	["ChargePads"] = {"charge pads"};
	["CompactSolars"] = {"compact solars", "compact solar arrays"};
	["Compact Windmills"] = {"cwm", "compactwindmills"};
	["ComputerCraft"] = {"cc"};
	["DartCraft"] = {"dc"};
	["Dimensional Doors"] = {"dd", "dimdoors", "dimensionaldoors"};
	["Emasher Resource"] = {"emasher"};
	["Ender Storage"] = {"enderchest", "enderchests", "enderstorage"};
	["Engineer's Toolbox"] = {"engineers toolbox"};
	["EnhancedPortals 2"] = {"ep2", "enhancedportals", "enhanced portals", "enhanced portals 2"};
	["Equivalent Exchange"] = {"ee"};
	["Equivalent Exchange 2"] = {"ee2"};
	["Equivalent Exchange 3"] = {"ee3"};
	["Extra Bees"] = {"eb", "extrabees"};
	["Extra Cells"] = {"ec", "extracells"};
	["EnderIO"] = {"eio", "ender io"};
	["Ex Nihilo"] = {"exn", "exnihilo"};
	["Extra Trees"] = {"et", "extratrees"};
	["ExtrabiomesXL"] = {"ebxl", "extrabiomes", "extrabiomes xl"};
	["Extra Utilities"] = {"eu", "extrautils"};
	["Factorization"] = {"fz"};
	["Forestry"] = {};
	["Forge IRC"] = {"forgeirc"};
	["Forge Mod Loader"] = {"fml", "forgeml", "forgemodloader", "forge modloader"};
	["GasCraft"] = {};
	["Gendustry"] = {};
	["Gravitation Suite"] = {"gravisuite"};
	["Gravity Gun"] = {"gravigun"};
	["GregTech"] = {"gt"};
	["Hardcore Ender Expansion"] = {"hee"};
	["Hardcore Questing Mode"] = {"hqm", "hardcore quest"};
	["IndustrialCraft 2"] = {"ic", "ic2", "industrialcraft", "industrialcraft2"};
	["IndustrialCraft 2 Experimental"] = {"ic2x", "ic2 exp", "industrialcraft2 experimental"};
	["ICBM"] = {};
	["Inventory Tweaks"] = {"invtweaks"};
	["Iron Chests"] = {"ironchests"};
	["JABBA"] = {};
	["Logistics Pipes"] = {"lp", "logipipes", "logisticpipes", "logisticspipes", "logistic pipes"};
	["Magic Bees"] = {"thaumic bees"};
	["Minecraft"] = {"mc", "vanilla", "vanillaminecraft", "vanilla minecraft"};
	["Minecraft Forge"] = {"forge", "mcforge", "minecraftforge"};
	["MineChem"] = {};
	["Mod Coder Pack"] = {"mcp", "minecraft coder pack"};
	["MineFactory Reloaded"] = {"mfr", "minefactory", "mine factory", "mine factory reloaded"};
	["Misc Peripherals"] = {"misc peripherals"};
	["Mekanism"] = {};
	["MFFS Calclavia"] = {};
	["Modular Force Field System"] = {"mffs"};
	["Modular Powersuits"] = {"mps", "modular power suits"};
	["Mystcraft"] = {};
	["Natura"] = {};
	["Nether Ores"] = {};
	["Not Enough Items"] = {"nei", "notenoughitems"};
	["Nuclear Control"] = {};
	["Obsidian Pressure Plates"] = {"obsidiplates", "obsidian plates"};
	["OmniTools"] = {};
	["OpenBlocks"] = {"ob"};
	["OpenComputers"] = {"oc", "opencomp", "opencomputers"};
	["Pam's HarvestCraft"] = {"pam", "ph", "hc", "phc", "pams harvestcraft"};
	["Petroleum Generator (Mod)"] = {"petrogen", "petro gen", "petroleum generator"};
	["Portal Gun (Mod)"] = {"pg", "pgm", "portalgun", "portal gun", "portal gun mod"};
	["Power Converters"] = {};
	["Professor Flagbeard's Wondrous Steam Power Mod"] = {"fsp", "fsm", "wsp", "pfwsp", "pfwspm", "steam power", "flaxbeard steam power", "flaxbeard's steam power"};
	["qCraft"] = {"qc"};
	["Railcraft"] = {"rc"};
	["RedPower 2"] = {"rp", "rp2", "redpower", "red power"};
	["Rei's Minimap"] = {"reiminimap", "rei minimap", "rei's minimap"};
	["Risugami's ModLoader"] = {"rml", "modloader", "mod loader"};
	["RotaryCraft"] = {};
	["Secret Rooms"] = {"secretrooms", "secretrooms mod", "secret rooms mod"};
	["Simply Jetpacks"] = {"sj", "simplyjetpacks"};
	["Soul Shards"] = {"soulshards"};
	["Steve's Carts 2"] = {"sc2", "steves carts", "steves carts 2", "steve's carts"};
	["Steve's Factory Manager"] = {"sfm", "steves factory manager"};
	["Sync"] = {};
	["Thaumcraft"] = {"tc"};
	["Thaumcraft 3"] = {"tc3"};
	["Thaumcraft 4"] = {"tc4", "tc4.1", "thaumcraft 4.1"};
	["Thermal Dynamics"] = {"td"};
	["Thermal Expansion"] = {"te"};
	["Thermal Expansion 2"] = {"te2"};
	["Thermal Expansion 3"] = {"te3"};
	["Thermal Expansion 4"] = {"te4"};
	["Thermal Foundation"] = {"tf"};
	["Tinkers' Construct"] = {"tic", "tcon", "tconstruct", "tinkers construct", "tinker's construct", "tinkerer's construct"};
	["TrainCraft"] = {"train craft"};
	["Tropicraft"] = {};
	["Thaumic Tinkerer"] = {"tt"};
	["Thaumic Tinkerer 2"] = {"tt2"};
	["TubeStuff"] = {};
	["Twilight Forest"] = {};
	["Wireless Redstone ChickenBones Edition"] = {"wrcbe", "wr-cbe", "wireless redstone", "wireless redstone cbe", "wireless redstone chicken bones edition"};
	["Xeno's Reliquary"] = {"reliquary", "xreliquary", "xenos reliquary"};
	["XyCraft"] = {};
}

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

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

-- Array of misc. suffixes to strip from item/block names 
p.miscSuffixes = {
	"Block",
	"Item",
}

for name, abbrs in pairs(p.name2abbrs) do
	for i, abbr in pairs(abbrs) do
		p.abbr2name[abbr] = name
	end
	p.abbr2name[string.lower(name)] = name
end

function p.getPagename(abbr)
	return p.abbr2name[string.lower(abbr)] or abbr
end

function p.getDisplayname(abbr)
	local pn = p.getPagename(abbr)
	return p.name2display[pn] or pn
end

function p.getWikilink(abbr, smwprop)
	labbr = string.lower(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

function p.stripSuffix(label)
	-- Pattern matching all bracketed suffixes (e.g. "(T E 4)", "(Block)", etc.)
	local suffix = label:match("%(.+%)$")
	if suffix ~= nil then
		local trimmed = suffix:sub(2, -2):lower()
		
		-- Augment mod name table with misc suffixes
		for i, name in ipairs(p.miscSuffixes) do
			p.name2abbrs[name] = {}
		end
		
		-- Walk names for match
		for name, v in pairs(p.name2abbrs) do
			if name:lower() == trimmed then
				return label:sub(1, -(#suffix + 2))
			end
		end
	end
	
	return label
end

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