Update from 22.06.2025: add MapGen mod outline, fix some require() issues

This commit is contained in:
2025-06-22 19:20:06 +07:00
parent 50606c7dfe
commit c0de09d597
45 changed files with 621 additions and 119 deletions

View File

@@ -1,11 +1,19 @@
_G.Require = {}
Require = {}
local loadedModules = {}
local DS = '/'
function Require.getModRequire()
return function(fileName)
local modName = self.name
local modPath = self.path
--- Creates a scoped require function for a specific module
--- This custom require handles module loading relative to a specific module path,
--- prevents duplicate loading, and caches results appropriately.
--- @param modName string Namespace identifier for the module (prevents global collisions)
--- @param modPath string Absolute base path to the module's directory
--- @return function require Custom require function scoped to the specified module
function Require.getModRequire(modName, modPath)
--- Custom require function for module-specific loading
--- Resolves files relative to modPath/src, converts dot-notation to path separators
--- @param fileName string Module path in dot-notation (e.g. "lib.utils")
--- @return any loadedModule The loaded module's return value or cached result
local function require(fileName)
local fullName = modName .. '..' .. fileName
local module = loadedModules[fullName]
@@ -23,4 +31,6 @@ function Require.getModRequire()
return loadedModules[fullName]
end
return require
end