Mod: add shortName

This commit is contained in:
Van
2025-09-23 18:38:39 +00:00
parent c3cde1fc63
commit cc19f2eb89

View File

@@ -1,20 +1,30 @@
--- Luanti mod --- Luanti mod
---@class Mod ---@class Mod
---@field public name string Technical name of the 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 path string Path to the mod folder.
---@field public Class table A public class that provides a mod. ---@field public Class table A public class that provides a mod.
---@field public require fun(FileName:string):table ---@field public require fun(FileName:string):table
Mod = {} Mod = {}
---Returns the mod name without prefixes
---@param name string
---@return string
function Mod.getShortModName(name)
local shortName = string.gsub(name, '%w*__', '')
return shortName
end
--- Return table with mod name, path and require function. --- Return table with mod name, path and require function.
---@return {name: string, path: string, require: fun(FileName : string): table} ---@return {name: string, shortName: string, path: string, require: fun(FileName : string): table}
function Mod.getInfo() function Mod.getInfo()
local name = core.get_current_modname() local name = core.get_current_modname()
local shortName = Mod.getShortModName(name)
local path = core.get_modpath(name) local path = core.get_modpath(name)
local require = Require.getModRequire(name, path) local require = Require.getModRequire(name, path)
return {name = name, path = path, require = require} return {name = name, shortName = shortName, path = path, require = require}
end end
function Mod:new() function Mod:new()