diff --git a/mods/CORE/Item/src/Item.lua b/mods/CORE/Item/src/Item.lua index ca846d4..6690a52 100644 --- a/mods/CORE/Item/src/Item.lua +++ b/mods/CORE/Item/src/Item.lua @@ -4,6 +4,14 @@ local tableCopy, tableMerge, colorize = table.copy, table.merge, core.colorize local ItemFactory = Smc.requireItemFactory() +---Colors the title according to the rarity of the item. +--- +---Note: that if `true`, the `_title_color` will be ignored. +local TITLE_RARITY_COLOR = true + +---Shows rarity on a separate line. +local SHOW_RARITY = false + ---Determines whether common rarity will be shown in item descriptions or not. local SHOW_COMMON_RARITY = true @@ -57,6 +65,10 @@ local Item = { ---@param desc string ---@return string local function addRarityToDesc(rarity, desc) + if not SHOW_RARITY then + return desc + end + if not SHOW_COMMON_RARITY and rarity == 'common' then return desc end @@ -98,15 +110,19 @@ local function itemDefToLuantiDef(itemDef) description = string.match(s.name, '%S:(%S+)')..'-desc' end + assert(s._rarity ~= nil, 'The rarity of an item cannot be empty.') + if s._title_color ~= nil and s._description_color ~= nil then - title = colorize(s._title_color , S(title)) + if TITLE_RARITY_COLOR then + title = colorize(RARITY_COLORS[s._rarity], S(title)) + else + title = colorize(s._title_color, S(title)) + end description = colorize(s._description_color, S(description)) else error('Item description color parameters cannot be empty.') end - assert(s._rarity ~= nil, 'The rarity of an item cannot be empty.') - local luantiDescription = addRarityToDesc(s._rarity, title..'\n '..description) s._title = title