From cc19f2eb89b50b33bda66932936e8826f34c3b53 Mon Sep 17 00:00:00 2001 From: Vanic Date: Tue, 23 Sep 2025 18:38:39 +0000 Subject: [PATCH] Mod: add shortName --- mods/API/Mod/init.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mods/API/Mod/init.lua b/mods/API/Mod/init.lua index 606c9ce..8e76fde 100644 --- a/mods/API/Mod/init.lua +++ b/mods/API/Mod/init.lua @@ -1,20 +1,30 @@ --- 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 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 {name: string, path: string, require: fun(FileName : string): table} +---@return {name: string, shortName: string, path: string, require: fun(FileName : string): table} function Mod.getInfo() local name = core.get_current_modname() + local shortName = Mod.getShortModName(name) local path = core.get_modpath(name) local require = Require.getModRequire(name, path) - return {name = name, path = path, require = require} + return {name = name, shortName = shortName, path = path, require = require} end function Mod:new()