Rename some mods

This commit is contained in:
Van
2025-12-30 17:53:26 +03:00
parent 475b199ddb
commit 44ba5c7cfa
20 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
-- World generation occurs in a separate thread (MapGen Environment).
-- But for the main thread, the mapgenerator object is also initialized.
local mapGeneneratorRequire = Mod.getInfo('smc__core__map_generator').require
-- Main env init
local mapGenerator = mapGeneneratorRequire('mapGenerator')
-- Async env init
core.register_mapgen_script(core.get_modpath('smc__core__map_generator')..'/src/asyncInit.lua')
-- --- Register vanilla ores & decorations ---
-- For now, the generation does not have its own support
-- for the generation of ores and decorations, so vanilla ones are used.
core.register_ore({
ore_type = "scatter",
ore = "soils:rocky_soil_baren",
wherein = "rocks:sylite",
clust_scarcity = 8*8*8,
clust_num_ores = 8,
clust_size = 3,
y_min = -31000,
y_max = 64,
})
core.register_decoration({
deco_type = "simple",
place_on = "soils:clay_soil_baren",
sidelen = 8,
fill_ratio = 0.1,
decoration = "plants:plants",
})
return mapGenerator

View File

@@ -0,0 +1,2 @@
name = smc__core__map_generator
depends = smc__core__map_gen, smc__game__items__rocks, smc__game__items__liquids

View File

@@ -0,0 +1,44 @@
-- MAPGEN ENVIROMENT ONLY
-- https://api.luanti.org/core-namespace-reference/#mapgen-environment
-- This environment is isolated from the main environment,
-- so global tables need to be preloaded manually.
-- --- Global APIs load --
-- Class
dofile(core.get_modpath('smc__api__class')..'/init.lua')
-- Ensure
dofile(core.get_modpath('smc__api__ensure')..'/init.lua')
-- Logger
dofile(core.get_modpath('smc__api__logger')..'/init.lua')
-- Math
dofile(core.get_modpath('smc__api__math')..'/init.lua')
-- Require
dofile(core.get_modpath('smc__api__require')..'/init.lua')
-- Mod
dofile(core.get_modpath('smc__api__mod')..'/init.lua')
-- TODO: исправить загрузку строковых библиотек (хотя они пока что не юзаются в мапгене)
-- Они не работают из-за get_current_modname внутри utf8
-- UTF-8
-- dofile(core.get_modpath('smc__api__utf8')..'/init.lua')
-- String
-- dofile(core.get_modpath('smc__api__string')..'/init.lua')
-- Table
dofile(core.get_modpath('smc__api__table')..'/init.lua')
-- TODO: пока что закоментировано, поскольку вызывает ошибку из-за global_step
-- Api loader
-- dofile(core.get_modpath('smc__api__api_loader')..'/init.lua')
---@type MapGen
local mapGenerator = dofile(core.get_modpath('smc__core__map_generator')..'/src/mapGenerator.lua')
mapGenerator:run()

View File

@@ -0,0 +1,217 @@
-- --- MapGen definiton ---
local id = core.get_content_id
local mathRound = math.round
local mapGenRequire = Mod.getInfo('smc__core__map_gen').require
---@type MapGen
local MapGen = mapGenRequire('MapGen')
---@type MapGen
local mapGenerator = MapGen:new({
nodes = {
-- Special nodes
air = 'air',
-- Rocks
sylite = 'rocks:sylite',
tauitite = 'rocks:tauitite',
iyellite = 'rocks:iyellite',
falmyte = 'rocks:falmyte',
hapcoryte = 'rocks:hapcoryte',
burcite = 'rocks:burcite',
felhor = 'rocks:felhor',
malachite = 'rocks:malachite',
-- Liquids
water = 'liquids:water_source',
},
})
local function calcTemp(layer, value, height)
return value
end
local function calcHumidity(layer, value, height)
return value
end
mapGenerator:registerLayer('midgard', {
minY = -256,
maxY = 256,
minTemp = -100,
maxTemp = 100,
minHumidity = 0,
maxHumidity = 100,
calcTemp = calcTemp,
calcHumidity = calcHumidity,
biomesVerticalScattering = 5,
biomesGorizontalScattering = 5
})
local land1 = {
offset = -20,
scale = 5,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 3,
persistence = 0.4,
lacunarity = 2,
}
local land2 = {
offset = 20,
scale = 5,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 3,
persistence = 0.4,
lacunarity = 2,
}
local climat1 = {
offset = 80,
scale = 10,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 8,
persistence = 0.6,
lacunarity = 2,
}
local climat2 = {
offset = 30,
scale = 10,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 8,
persistence = 0.6,
lacunarity = 2,
}
local climat0 = {
offset = 50,
scale = 0,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 8,
persistence = 0.4,
lacunarity = 2,
}
local v = vector.new
mapGenerator:register2DPeaks('midgard',
{
landscapeNoise = land1,
tempNoise = climat2,
humidityNoise = climat2,
},{
v(500, 0, 500),
v(-500, 0, -500),
v(-500, 0, 500),
v(500, 0, -500),
})
mapGenerator:register2DPeaks('midgard',
{
landscapeNoise = land2,
tempNoise = climat1,
humidityNoise = climat1,
},{
v(-300, 0, 300),
v(200, 0, -400),
})
mapGenerator:register2DPeaks('midgard',
{
landscapeNoise = land2,
tempNoise = climat2,
humidityNoise = climat2,
},{
v(200, 0, 100),
v(-300, 0, -200),
})
mapGenerator:registerCavern('midgard', 'cavern1', {
minY = -48,
maxY = 0,
smoothDistance = 20,
threshold = 0.3,
noiseParams ={
offset = 0,
scale = 1,
spread = {x = 25, y = 25, z = 25},
seed = 5934,
octaves = 3,
persistence = 0.5,
lacunarity = 2.0
},
})
-- --- Biomes ---
---@type ValueNoise
local rocksNoise
---@type NoiseParams
local rocksNoiseParams ={
offset = 4,
scale = 2,
spread = {x = 30, y = 30, z = 30},
seed = 47,
octaves = 3,
persistence = 0.5,
lacunarity = 4,
}
local function generateRock(biome, mapGenerator, data, index, x, y, z)
local ids = mapGenerator.nodeIDs
if rocksNoise == nil then
rocksNoise = core.get_value_noise(rocksNoiseParams)
end
local noiseRocksValue = mathRound(rocksNoise:get_3d({x = x, y = y, z = z}))
if noiseRocksValue == 1 then
data[index] = ids.malachite
elseif noiseRocksValue == 2 then
data[index] = ids.hapcoryte
elseif noiseRocksValue == 3 then
data[index] = ids.iyellite
elseif noiseRocksValue == 4 then
data[index] = ids.sylite
elseif noiseRocksValue == 5 then
data[index] = ids.tauitite
elseif noiseRocksValue == 6 then
data[index] = ids.falmyte
elseif noiseRocksValue == 7 then
data[index] = ids.burcite
elseif noiseRocksValue == 8 then
data[index] = ids.felhor
end
end
---@param biome MapGen.Biome
local function generateSoil(biome, mapGenerator, data, index, x, y, z)
data[index] = biome.groundNodesIDs.turf
end
mapGenerator:registerBiome('midgard', 'swamp', {
tempPoint = 0,
humidityPoint = 80,
minY = 100,
maxY = 0,
groundNodes = {
soil = 'soils:clay_soil_baren',
turf = 'soils:clay_soil_baren',
rock = 'rocks:sylite',
bottom = 'soils:rocky_soil_baren',
},
soilHeight = 3,
generateRock = generateRock,
generateSoil = generateSoil,
})
return mapGenerator