Compare commits
3 Commits
e98935cf6f
...
44916bcd3b
| Author | SHA1 | Date | |
|---|---|---|---|
| 44916bcd3b | |||
| 3483cd650a | |||
| c4104a1834 |
@@ -24,7 +24,6 @@ function BaseUI:new(name, getFormSpecString, clearContex)
|
|||||||
instance.getFormSpecString = getFormSpecString
|
instance.getFormSpecString = getFormSpecString
|
||||||
|
|
||||||
if clearContex then
|
if clearContex then
|
||||||
core.log(name)
|
|
||||||
-- Ensure that when the form is closed, the context is cleared.
|
-- Ensure that when the form is closed, the context is cleared.
|
||||||
instance:registerOnFormQuit(function(player)
|
instance:registerOnFormQuit(function(player)
|
||||||
instance:clearContex(player)
|
instance:clearContex(player)
|
||||||
|
|||||||
@@ -4,6 +4,14 @@ local tableCopy, tableMerge, colorize = table.copy, table.merge, core.colorize
|
|||||||
|
|
||||||
local ItemFactory = Smc.requireItemFactory()
|
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.
|
---Determines whether common rarity will be shown in item descriptions or not.
|
||||||
local SHOW_COMMON_RARITY = true
|
local SHOW_COMMON_RARITY = true
|
||||||
|
|
||||||
@@ -57,6 +65,10 @@ local Item = {
|
|||||||
---@param desc string
|
---@param desc string
|
||||||
---@return string
|
---@return string
|
||||||
local function addRarityToDesc(rarity, desc)
|
local function addRarityToDesc(rarity, desc)
|
||||||
|
if not SHOW_RARITY then
|
||||||
|
return desc
|
||||||
|
end
|
||||||
|
|
||||||
if not SHOW_COMMON_RARITY and rarity == 'common' then
|
if not SHOW_COMMON_RARITY and rarity == 'common' then
|
||||||
return desc
|
return desc
|
||||||
end
|
end
|
||||||
@@ -98,15 +110,19 @@ local function itemDefToLuantiDef(itemDef)
|
|||||||
description = string.match(s.name, '%S:(%S+)')..'-desc'
|
description = string.match(s.name, '%S:(%S+)')..'-desc'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert(s._rarity ~= nil, 'The rarity of an item cannot be empty.')
|
||||||
|
|
||||||
if s._title_color ~= nil and s._description_color ~= nil then
|
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))
|
description = colorize(s._description_color, S(description))
|
||||||
else
|
else
|
||||||
error('Item description color parameters cannot be empty.')
|
error('Item description color parameters cannot be empty.')
|
||||||
end
|
end
|
||||||
|
|
||||||
assert(s._rarity ~= nil, 'The rarity of an item cannot be empty.')
|
|
||||||
|
|
||||||
local luantiDescription = addRarityToDesc(s._rarity, title..'\n '..description)
|
local luantiDescription = addRarityToDesc(s._rarity, title..'\n '..description)
|
||||||
|
|
||||||
s._title = title
|
s._title = title
|
||||||
|
|||||||
@@ -64,3 +64,26 @@ function Smc.requireFormspec()
|
|||||||
return class
|
return class
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@return CraftSystem
|
||||||
|
function Smc.requireCraftSystem()
|
||||||
|
---@type CraftSystem
|
||||||
|
local class = Mod.getInfo('smc__core__craft_system').require('CraftSystem')
|
||||||
|
|
||||||
|
return class
|
||||||
|
end
|
||||||
|
|
||||||
|
---@return CraftSystem.PrimitiveCraftHandler
|
||||||
|
function Smc.requireCraftSystemPrimitiveCraftHandler()
|
||||||
|
---@type CraftSystem.PrimitiveCraftHandler
|
||||||
|
local class = Mod.getInfo('smc__core__craft_system').require('CraftSystem.PrimitiveCraftHandler')
|
||||||
|
|
||||||
|
return class
|
||||||
|
end
|
||||||
|
|
||||||
|
---@return CraftSystem.ImmersiveCraftHandler
|
||||||
|
function Smc.requireCraftSystemImmersiveCraftHandler()
|
||||||
|
---@type CraftSystem.ImmersiveCraftHandler
|
||||||
|
local class = Mod.getInfo('smc__core__craft_system').require('CraftSystem.ImmersiveCraftHandler')
|
||||||
|
|
||||||
|
return class
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user