Write Class lib

This commit is contained in:
Van
2025-12-01 17:06:48 +03:00
parent f9eccced09
commit ace217832b
4 changed files with 19 additions and 3 deletions

View File

@@ -1,3 +1,3 @@
name = smc__api__api_loader
description = Include this mod in your `depends` to ensure all necessary APIs are loaded for your mod
depends = smc__api__ensure, smc__api__math, smc__api__mod, smc__api__require, smc__api__table, smc__api__string, smc__api__utf8,
depends = smc__api__ensure, smc__api__math, smc__api__mod, smc__api__require, smc__api__table, smc__api__string, smc__api__utf8, smc__api__class

9
mods/API/Class/init.lua Normal file
View File

@@ -0,0 +1,9 @@
---@class Class
Class = {}
---Returns a child class with inherited parameters from the parent class.
---@param parent table
---@param child table
function Class.extend(parent ,child)
return setmetatable(child or {}, { __index = parent })
end

1
mods/API/Class/mod.conf Normal file
View File

@@ -0,0 +1 @@
name = smc__api__class

View File

@@ -5,6 +5,12 @@
-- so global tables need to be preloaded manually.
-- --- Global APIs load --
-- Api loader
dofile(core.get_modpath('smc__api__api_loader')..'/init.lua')
-- Class
dofile(core.get_modpath('smc__api__class')..'/init.lua')
-- Ensure
dofile(core.get_modpath('smc__api__ensure')..'/init.lua')
@@ -170,8 +176,8 @@ mapGenerator:register2DPeaks("world",
})
mapGenerator:registerCavern('world', 'cavern1', {
minY = -100,
maxY = -10,
minY = -48,
maxY = 0,
smoothDistance = 20,
threshold = 0.3,
noiseParams ={