Annotations changes: clarification of types, addition of missing annotations

This commit is contained in:
Van
2025-10-03 20:50:14 +03:00
parent ab92e372f3
commit 69b8c6469c
13 changed files with 129 additions and 84 deletions

View File

@@ -1,10 +1,10 @@
--- Luanti mod
---Luanti mod
---@class Mod
---@field public name string Technical name of the mod.
---@field public shortName string
---@field public path string Path to the mod folder.
---@field public Class table A public class that provides a mod.
---@field public require fun(FileName:string):table
---@field name string Technical name of the mod.
---@field shortName string
---@field path string Path to the mod folder.
---@field Class table A public class that provides a mod.
---@field require fun(FileName:string):table
Mod = {}
---Returns the mod name without prefixes
@@ -16,7 +16,7 @@ local function getShortModName(name)
return shortName
end
--- Return table with mod name, path and require function.
---Return table with mod name, path and require function.
---@return {name: string, shortName: string, path: string, require: fun(FileName : string): table}
function Mod.getInfo()
local name = core.get_current_modname()
@@ -29,40 +29,36 @@ end
function Mod:new()
---@type Mod
self = setmetatable(Mod.getInfo(), { __index = self })
return self
end
--- Get an instance of a public class provided by a mod
---@param ... any?
---@return table
-- TODO: возможно стоит создать какой-то абстрактный класс,
-- который будет является алеасом на table и будет обозначать наш класс
function Mod:getModClassInstance(...)
local instance = self.Class:new(...)
local instance = setmetatable(Mod.getInfo(), { __index = self })
return instance
end
--- Inherits a child class from a parent class
---@static
---Get an instance of a public class provided by a mod
---@param ... any?
---@return table
function Mod:getModClassInstance(...)
local classInstance = self.Class:new(...)
return classInstance
end
---Inherits a child class from a parent class
---@param ParentClass table
---@param ChildClass table?
---@return table
---@return table
function Mod:getClassExtended(ParentClass, ChildClass)
local ChildClass = setmetatable(ChildClass or {}, { __index = ParentClass })
local childClass = setmetatable(ChildClass or {}, { __index = ParentClass })
return ChildClass
return childClass
end
--- Inherits a child class from a parent public class provided by the mod.
---@static
---Inherits a child class from a parent public class provided by the mod.
---@param ChildClass table?
---@return table
---@return table
function Mod:getModClassExtended(ChildClass)
local ChildClass = Mod:getClassExtended(self.Class, ChildClass or {})
local childClass = Mod:getClassExtended(self.Class, ChildClass or {})
return ChildClass
return childClass
end