From e435b21b43427c4eeaa65361853bcbd191ea29c1 Mon Sep 17 00:00:00 2001 From: Vanic Date: Mon, 2 Feb 2026 14:25:20 +0300 Subject: [PATCH] `Item`: Corrections to the design, added the last empty lines --- mods/CORE/Item/init.lua | 2 +- mods/CORE/Item/locale/item.ru.tr | 2 +- mods/CORE/Item/src/Item.lua | 38 +++++++++++++-------------- mods/CORE/Item/src/Item/Callbacks.lua | 2 +- mods/CORE/Item/src/Item/Rarity.lua | 2 +- mods/CORE/Item/src/Item/Settings.lua | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/mods/CORE/Item/init.lua b/mods/CORE/Item/init.lua index 3b665cb..505e088 100644 --- a/mods/CORE/Item/init.lua +++ b/mods/CORE/Item/init.lua @@ -1,4 +1,4 @@ local modInfo = Mod.getInfo('smc__core__item') local require = modInfo.require -return require('Item') \ No newline at end of file +return require('Item') diff --git a/mods/CORE/Item/locale/item.ru.tr b/mods/CORE/Item/locale/item.ru.tr index a73273c..e0f1db2 100644 --- a/mods/CORE/Item/locale/item.ru.tr +++ b/mods/CORE/Item/locale/item.ru.tr @@ -6,4 +6,4 @@ uncommon=необычный distinguished=выдающийся eminent=исключительный prime=Превосходный -unique=Уникальный \ No newline at end of file +unique=Уникальный diff --git a/mods/CORE/Item/src/Item.lua b/mods/CORE/Item/src/Item.lua index 5506996..95611dd 100644 --- a/mods/CORE/Item/src/Item.lua +++ b/mods/CORE/Item/src/Item.lua @@ -33,10 +33,10 @@ local RARITY_INDEX = { } ---@class Item ----@field itemDef Item.ItemDefinition ----@field luantiDef table ----@field getVisual fun(): string ----@field defaultDef Item.ItemDefinition +---@field itemDef Item.ItemDefinition +---@field luantiDef ItemDefinition +---@field getVisual fun(): string +---@field defaultDef Item.ItemDefinition local Item = { defaultDef = { settings = { @@ -122,19 +122,19 @@ local function itemDefToLuantiDef(itemDef) return luantiDef end ----@param luantiDef NodeDefinition|ItemDefinition +---@param luantiDef NodeDefinition local function register3dItem(luantiDef) - local ld = luantiDef - local name = ld.name - ld.name = nil + local name = luantiDef.name + luantiDef.name = nil + core.register_node(':'..name, luantiDef) end ---@param luantiDef ItemDefinition local function registerFlatItem(luantiDef) - local ld = luantiDef - local name = ld.name - ld.name = nil + local name = luantiDef.name + luantiDef.name = nil + core.register_craftitem(':'..name, luantiDef) end @@ -144,23 +144,23 @@ local defMerge = function(...) return table.merge(...) end ----@param itemDef Item.ItemDefinition|Node.NodeDefinition ----@return Item -function Item:new(itemDef) +---@param def Item.ItemDefinition|Node.NodeDefinition +---@return Item +function Item:new(def) ---Adding default parameters - itemDef = defMerge(itemDef, self.defaultDef, true) + def = defMerge(def, self.defaultDef, true) ---@type Item local instance = getInstance(self, {}) - local luantiDef = itemDefToLuantiDef(itemDef) - local visual = itemDef.settings.visual + local luantiDef = itemDefToLuantiDef(def) + local visual = def.settings.visual if visual == nil then visual = 'item_2d' end - itemDef.settings.visual = nil + def.settings.visual = nil if visual == 'item_3d' then register3dItem(luantiDef) @@ -173,7 +173,7 @@ function Item:new(itemDef) return visual end - instance.itemDef = itemDef + instance.itemDef = def instance.luantiDef = luantiDef return instance diff --git a/mods/CORE/Item/src/Item/Callbacks.lua b/mods/CORE/Item/src/Item/Callbacks.lua index 33f53b8..79e0679 100644 --- a/mods/CORE/Item/src/Item/Callbacks.lua +++ b/mods/CORE/Item/src/Item/Callbacks.lua @@ -64,4 +64,4 @@ Callbacks.on_use = nil ---@type fun(itemstack:ItemStack, user:Player|ObjectRef|nil, node, digparams)? Callbacks.after_use = nil -return Callbacks \ No newline at end of file +return Callbacks diff --git a/mods/CORE/Item/src/Item/Rarity.lua b/mods/CORE/Item/src/Item/Rarity.lua index 914e0d4..62af342 100644 --- a/mods/CORE/Item/src/Item/Rarity.lua +++ b/mods/CORE/Item/src/Item/Rarity.lua @@ -5,4 +5,4 @@ --- * `eminent` --- * `prime` --- * `unique` ----@alias Item.Rarity 'common'|'uncommon'|'distinguished'|'eminent'|'prime'|'unique' \ No newline at end of file +---@alias Item.Rarity 'common'|'uncommon'|'distinguished'|'eminent'|'prime'|'unique' diff --git a/mods/CORE/Item/src/Item/Settings.lua b/mods/CORE/Item/src/Item/Settings.lua index d3de7af..584cfc8 100644 --- a/mods/CORE/Item/src/Item/Settings.lua +++ b/mods/CORE/Item/src/Item/Settings.lua @@ -186,4 +186,4 @@ Settings.touch_interaction = nil Settings.sound = nil -return Settings \ No newline at end of file +return Settings