From d5c58862d29f43f80c3b1390e9bfdfbfe5c493d6 Mon Sep 17 00:00:00 2001 From: Vanic Date: Fri, 29 Aug 2025 19:44:35 +0000 Subject: [PATCH] Add annotation to class `Item` --- mods/CORE/Item/init.lua | 2 -- mods/CORE/Item/src/Item.lua | 16 ++++++++++++++-- mods/CORE/Item/src/ItemDefinition.lua | 5 +++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mods/CORE/Item/init.lua b/mods/CORE/Item/init.lua index 59c4b69..c9afe9f 100644 --- a/mods/CORE/Item/init.lua +++ b/mods/CORE/Item/init.lua @@ -3,5 +3,3 @@ local Item = Mod:new() Item.Class = Item.require('Item') Api.addModToGlobalSpace(Item, 'Core.Item') - - diff --git a/mods/CORE/Item/src/Item.lua b/mods/CORE/Item/src/Item.lua index fea2cd3..c4d68ef 100644 --- a/mods/CORE/Item/src/Item.lua +++ b/mods/CORE/Item/src/Item.lua @@ -1,6 +1,12 @@ -local Item = {} +---@class Item +---@field itemDef ItemDefinition +---@field luantiDef table +local Item = { + itemDef = nil, + luantiDef = nil, +} ---- @param itemDef ItemDefinition +---@param itemDef ItemDefinition local function itemDefToLuantiDef(itemDef) itemDef = table.copy(itemDef) local s = itemDef.settings @@ -13,6 +19,7 @@ local function itemDefToLuantiDef(itemDef) return luantiDef end +---@param luantiDef table local function register3dItem(luantiDef) local ld = luantiDef local name = ld.name @@ -20,6 +27,7 @@ local function register3dItem(luantiDef) core.register_node(':'..name, luantiDef) end +---@param luantiDef table local function registerFlatItem(luantiDef) local ld = luantiDef local name = ld.name @@ -27,6 +35,8 @@ local function registerFlatItem(luantiDef) core.register_craftitem(':'..name, luantiDef) end +---@param itemDef ItemDefinition +---@return Item function Item:new(itemDef) local instance = {} local luantiDef = itemDefToLuantiDef(itemDef) @@ -49,4 +59,6 @@ function Item:new(itemDef) return instance end + + return Item diff --git a/mods/CORE/Item/src/ItemDefinition.lua b/mods/CORE/Item/src/ItemDefinition.lua index e89f3b2..51a7e33 100644 --- a/mods/CORE/Item/src/ItemDefinition.lua +++ b/mods/CORE/Item/src/ItemDefinition.lua @@ -1,5 +1,6 @@ ---- @class ItemDefinition ---- @field settings table +---@class ItemDefinition +---@field settings table +---@field callbacks table local ItemDefinition = { settings = { name = '',