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 = multiRequire('Module:Statname/aliases', 'Module:RarityTier/Aliases', 'Module:RarityTier/Data')

--Begin Exports local p = {}

local characters = { ['health'] = '❤', ['defense'] = '❈', ['strength'] = '❁', ['speed'] = '✦', ['crit chance'] = '☣', ['crit damage'] = '☠', ['intelligence'] = '✎', ['sea creature chance'] = '∞', ['magic find'] = '✯', ['pet luck'] = '♣', ['true defense'] = '❂', ['attack speed'] = '⚔', ['ferocity'] = '⫽', ['ability damage'] = '✹', ['mining speed'] = '⸕', ['mining fortune'] = '☘', ['farming fortune'] = '☘', ['foraging fortune'] = '☘', }

local statColors = { ['health'] = 'red', ['defense'] = 'green', ['strength'] = 'red', ['speed'] = 'white', ['crit chance'] = 'blue', ['crit damage'] = 'blue', ['intelligence'] = 'light aqua', ['sea creature chance'] = 'aqua', ['magic find'] = 'light aqua', ['pet luck'] = 'light purple', ['true defense'] = 'white', ['attack speed'] = 'yellow', ['ferocity'] = 'red', ['ability damage'] = 'red', ['mining speed'] = 'gold', ['mining fortune'] = 'gold', ['farming fortune'] = 'gold', ['foraging fortune'] = 'gold', }

local conversions = { ['black'] = 0, ['dark_blue'] = 1, ['dark_green'] = 2, ['dark_aqua'] = 3, ['dark_red'] = 4, ['dark_purple'] = 5, ['gold'] = 6, ['gray'] = 7, ['dark_gray'] = 8, ['blue'] = 9, ['green'] = 'a', ['aqua'] = 'b', ['red'] = 'c', ['light_purple'] = 'd', ['yellow'] = 'e', ['white'] = 'f', ['minecoin_gold'] = 'g', }

local rarityColors = { ['common'] = 'white', ['uncommon'] = 'green', ['rare'] = 'blue', ['epic'] = 'dark_purple', ['legendary'] = 'gold', ['mythic'] = 'light_purple', ['supreme'] = 'dark_red', ['special'] = 'red', ['very special'] = 'red', }

- -- 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(conversions[rarityColors[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('\n', '/')		:gsub('\\n', '/')) end --Finish Module/Exports return p