Add annotation to class Item
This commit is contained in:
@@ -3,5 +3,3 @@ local Item = Mod:new()
|
|||||||
Item.Class = Item.require('Item')
|
Item.Class = Item.require('Item')
|
||||||
|
|
||||||
Api.addModToGlobalSpace(Item, 'Core.Item')
|
Api.addModToGlobalSpace(Item, 'Core.Item')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
local function itemDefToLuantiDef(itemDef)
|
||||||
itemDef = table.copy(itemDef)
|
itemDef = table.copy(itemDef)
|
||||||
local s = itemDef.settings
|
local s = itemDef.settings
|
||||||
@@ -13,6 +19,7 @@ local function itemDefToLuantiDef(itemDef)
|
|||||||
return luantiDef
|
return luantiDef
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param luantiDef table
|
||||||
local function register3dItem(luantiDef)
|
local function register3dItem(luantiDef)
|
||||||
local ld = luantiDef
|
local ld = luantiDef
|
||||||
local name = ld.name
|
local name = ld.name
|
||||||
@@ -20,6 +27,7 @@ local function register3dItem(luantiDef)
|
|||||||
core.register_node(':'..name, luantiDef)
|
core.register_node(':'..name, luantiDef)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param luantiDef table
|
||||||
local function registerFlatItem(luantiDef)
|
local function registerFlatItem(luantiDef)
|
||||||
local ld = luantiDef
|
local ld = luantiDef
|
||||||
local name = ld.name
|
local name = ld.name
|
||||||
@@ -27,6 +35,8 @@ local function registerFlatItem(luantiDef)
|
|||||||
core.register_craftitem(':'..name, luantiDef)
|
core.register_craftitem(':'..name, luantiDef)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param itemDef ItemDefinition
|
||||||
|
---@return Item
|
||||||
function Item:new(itemDef)
|
function Item:new(itemDef)
|
||||||
local instance = {}
|
local instance = {}
|
||||||
local luantiDef = itemDefToLuantiDef(itemDef)
|
local luantiDef = itemDefToLuantiDef(itemDef)
|
||||||
@@ -49,4 +59,6 @@ function Item:new(itemDef)
|
|||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Item
|
return Item
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
--- @class ItemDefinition
|
---@class ItemDefinition
|
||||||
--- @field settings table
|
---@field settings table
|
||||||
|
---@field callbacks table
|
||||||
local ItemDefinition = {
|
local ItemDefinition = {
|
||||||
settings = {
|
settings = {
|
||||||
name = '',
|
name = '',
|
||||||
|
|||||||
Reference in New Issue
Block a user