Module:Mods

From Feed The Beast Wiki
Jump to: navigation, search

Exports

The below four functions accept a frame containing their arguments as well as the arguments directly, so they can be used with #invoke.

link(string)

Generate a link to the given mod (named by unlocalised name or abbreviation).

link(string,string)

Generate a link to the given mod (named by unlocalised name or abbreviation). Use the second argument as the link text.

getAbbrv(string)

Given an unlocalised name or abbreviation, return the abbreviation.

getName(string)

Given an unlocalised name or abbreviation, return the localised name.

Data format

The top of this module defines the list of mods, in the form of a table. Keys are mod abbreviations, while values are a list of strings, {link, name, localisedName}

keyvalue
linkRequired name of the mod's page.
nameOptional unlocalised name of the mod if it isn't the same as the name of its page.
localisedNameRequired localised name of the mod.

local util = require('Module:Utility_functions')

local success, mods = util.requireDataLocalised('Module:Mods/list')

local function getData(name)
    return mods.byAbbrv[name] or mods.byName[name] or {}
end

local function getLink(abbr, text)
    local mod = getData(abbr)
    return '[['.. ( mod.link or abbr ) .. util.pageSuffix() .. '|' .. ( text or mod.localised or abbr ) .. ']]'
end

local function getAbbrv(name)
   return getData(name).abbr or name
end

local function getName(name)
   return getData(name).localised or name
end

local function getNameUntranslated(name)
   return getData(name).name or name
end

return {
    
    getData = util.wrapForInvoke(getData),
    getLink = util.wrapForInvoke(getLink),
    getAbbrv = util.wrapForInvoke(getAbbrv),
    getName = util.wrapForInvoke(getName),
    getNameUntranslated = util.wrapForInvoke(getNameUntranslated)
}