Mod & Require: add load function
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
---Luanti mod
|
||||
---@class Mod
|
||||
---@field name string Technical name of the mod.
|
||||
---@field shortName string
|
||||
---@field path string Path to the mod folder.
|
||||
---@field Class any A public class that provides a mod.
|
||||
---@field require fun(FileName:string):table
|
||||
Mod = {}
|
||||
|
||||
---@class Mod.Info
|
||||
---@field name string
|
||||
---@field shortName string
|
||||
---@field path string
|
||||
---@field require fun(fileName:string):table
|
||||
---@field load fun(class:table, fileName:string)
|
||||
|
||||
---Returns the mod name without prefixes
|
||||
---@param name string
|
||||
---@return string
|
||||
@@ -18,15 +20,24 @@ end
|
||||
|
||||
---Return table with mod name, path and require function.
|
||||
---@param modname? string Specify a name of mod to get its info
|
||||
---@return {name: string, shortName: string, path: string, require: fun(FileName : string): table}
|
||||
---@return Mod.Info
|
||||
function Mod.getInfo(modname)
|
||||
local name = modname or core.get_current_modname()
|
||||
local shortName = getShortModName(name)
|
||||
local path = core.get_modpath(name)
|
||||
assert(path ~= nil, ('A mod `%s` does not exist.'):format(name))
|
||||
local require = Require.getModRequire(name, path)
|
||||
local require = Require:getModRequire(name, path)
|
||||
local load = Require:getModLoad(name, path)
|
||||
|
||||
return {name = name, shortName = shortName, path = path, require = require}
|
||||
local info = {
|
||||
name = name,
|
||||
shortName = shortName,
|
||||
path = path,
|
||||
require = require,
|
||||
load = load
|
||||
}
|
||||
|
||||
return info
|
||||
end
|
||||
|
||||
--[[
|
||||
@@ -65,4 +76,4 @@ function Mod:getModClassExtended(ChildClass)
|
||||
return childClass
|
||||
end --]]
|
||||
|
||||
return Mod
|
||||
return Mod
|
||||
|
||||
Reference in New Issue
Block a user