Module:UIText

--Get Required Modules local getArgs = require('Module:Arguments').getArgs local multiRequire = require('Module:MultiRequire') local string, table, lu, yesno = multiRequire('Module:String', 'Module:Table', 'Module:LibraryUtil', 'Module:Yesno') local statAliases, rarityAliases, rarityData, data = multiRequire('Module:Statname/aliases', 'Module:RarityTier/Aliases', 'Module:RarityTier/Data', 'Module:UIText/Data')

--Begin Exports local p = {}

local characters = data.characters local statColors = data.statColors local conversions = data.conversions local rarityColors = data.rarityColors - -- Temlate: UIText -- -- Makes making UI's alot easier - function p.main(frame) local args = getArgs(frame) local val = args[1] or args["t"] or args["text"]

return string.pcall(p._main, val) end - -- Template: UIText Module access point - function p._main(val) checkType('_main', 1, val, 'string') local function replaceRarities(rarity) local rarity = rarityAliases[string.trim((rarity:lower:gsub('%s', ' ')))] or formattedError('Invalid rarity escape "\\rarity{%s}"', 4, rarity) return ('&%s&l%s&r'):format(p.getRarityColor(rarity), rarityData[rarity].name) end local function replaceStats(statname) local prefix = statname:match('^([%-%+]?[%.%dkm,]+%%?)%s*') statname = string.trim((statname:gsub('^([%-%+]?[%.%dkm,]+%%?)%s*', ''))) stat = statAliases[statname:lower:gsub('%s', ' ')] or formattedError('Invalid stat escape "\\stat{%s}"', 4, statname) return ('&%s%s%s %s&r'):format(conversions[statColors[stat]], prefix and prefix..' ' or '', characters[stat], string.ucfirst(stat)) end return (string.unicodeConvert(val)		:gsub('\\sta?t?%{(.-)%}', replaceStats)		:gsub('\\ra?r?i?t?y?%{(.-)%}', replaceRarities)		:gsub('/', '\\/')		:gsub('\\/', '/')		:gsub('\n', '/')		:gsub('\\n', '/')) end

- -- function: getRarityColor(rarity: string) -- -- Gets the In-game color code of a rarity - function p.getRarityColor(rarity) checkType(1, rarity, { 'string' }) return conversions[rarityColors[rarityAliases[string.trim((rarity:lower:gsub('%s', ' ')))]]] end --Finish Module/Exports return p