Item: minor changes
This commit is contained in:
@@ -91,10 +91,6 @@ local function itemDefToLuantiDef(itemDef)
|
|||||||
local s = itemDef.settings
|
local s = itemDef.settings
|
||||||
local c = itemDef.callbacks
|
local c = itemDef.callbacks
|
||||||
|
|
||||||
if s._add_mod_name then
|
|
||||||
s.name = modName .. ':' .. s.name
|
|
||||||
end
|
|
||||||
|
|
||||||
local title = s._title
|
local title = s._title
|
||||||
local description = s._description
|
local description = s._description
|
||||||
|
|
||||||
@@ -146,28 +142,33 @@ local defMerge = function(...)
|
|||||||
return tableMerge(...)
|
return tableMerge(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param def Item.ItemDefinition|Node.NodeDefinition
|
---@param itemDef Item.ItemDefinition|Node.NodeDefinition
|
||||||
---@return Item
|
---@return Item
|
||||||
function Item:new(def)
|
function Item:new(itemDef)
|
||||||
assert(def.settings.description == nil,
|
assert(itemDef.settings.description == nil,
|
||||||
'The item description was specified using `description`, not `_description`. '..
|
'The item description was specified using `description`, not `_description`. '..
|
||||||
'Please note that the `description` field should not be used when registering an item. '..
|
'Please note that the `description` field should not be used when registering an item. '..
|
||||||
'Use `_title` and `_description` instead.')
|
'Use `_title` and `_description` instead.')
|
||||||
|
|
||||||
---Adding default parameters
|
-- Adding default parameters
|
||||||
def = defMerge(def, self.defaultDef, true)
|
itemDef = defMerge(itemDef, self.defaultDef, true)
|
||||||
|
local s = itemDef.settings
|
||||||
|
|
||||||
|
if s._add_mod_name then
|
||||||
|
s.name = Mod.getInfo().shortName .. ':' .. s.name
|
||||||
|
end
|
||||||
|
|
||||||
---@type Item
|
---@type Item
|
||||||
local instance = getInstance(self, {})
|
local instance = getInstance(self, {})
|
||||||
|
|
||||||
local luantiDef = itemDefToLuantiDef(def)
|
local luantiDef = itemDefToLuantiDef(itemDef)
|
||||||
local visual = def.settings._visual
|
local visual = itemDef.settings._visual
|
||||||
|
|
||||||
if visual == nil then
|
if visual == nil then
|
||||||
visual = 'item_2d'
|
visual = 'item_2d'
|
||||||
end
|
end
|
||||||
|
|
||||||
def.settings._visual = nil
|
itemDef.settings._visual = nil
|
||||||
|
|
||||||
if visual == 'item_3d' then
|
if visual == 'item_3d' then
|
||||||
register3dItem(luantiDef)
|
register3dItem(luantiDef)
|
||||||
@@ -180,7 +181,7 @@ function Item:new(def)
|
|||||||
return visual
|
return visual
|
||||||
end
|
end
|
||||||
|
|
||||||
instance.itemDef = def
|
instance.itemDef = itemDef
|
||||||
instance.luantiDef = luantiDef
|
instance.luantiDef = luantiDef
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
|||||||
Reference in New Issue
Block a user