Add test map image parsing

This commit is contained in:
Van
2026-01-10 12:04:25 +03:00
parent 7658d74387
commit 52630eb85a
4 changed files with 29 additions and 6 deletions

View File

@@ -244,6 +244,7 @@ function MapGen:register2DPeaksFromFile(layerName, map, zeroPos,peakColors)
local modPath = core.get_modpath(core.get_current_modname()) local modPath = core.get_modpath(core.get_current_modname())
local peaks = Api.ff2luat(modPath .. '/textures/maps/' .. map) local peaks = Api.ff2luat(modPath .. '/textures/maps/' .. map)
local mapSize = peaks.size local mapSize = peaks.size
peaks.size = nil
print(dump(peaks)) print(dump(peaks))
for color, peaksPos in pairs(peaks) do for color, peaksPos in pairs(peaks) do

View File

@@ -37,6 +37,8 @@ dofile(core.get_modpath('smc__api__table')..'/init.lua')
-- TODO: пока что закоментировано, поскольку вызывает ошибку из-за global_step -- TODO: пока что закоментировано, поскольку вызывает ошибку из-за global_step
-- Api loader -- Api loader
-- dofile(core.get_modpath('smc__api__api_loader')..'/init.lua') -- dofile(core.get_modpath('smc__api__api_loader')..'/init.lua')
Api = {}
dofile(core.get_modpath('smc__api__api_loader')..'/src/Api/ff2lua.lua')
---@type MapGen ---@type MapGen
local mapGenerator = dofile(core.get_modpath('smc__core__map_generator')..'/src/mapGenerator.lua') local mapGenerator = dofile(core.get_modpath('smc__core__map_generator')..'/src/mapGenerator.lua')

View File

@@ -61,7 +61,7 @@ local land1 = {
} }
local land2 = { local land2 = {
offset = 20, offset = 10,
scale = 5, scale = 5,
spread = {x = 30, y = 30, z = 30}, spread = {x = 30, y = 30, z = 30},
seed = 47, seed = 47,
@@ -133,22 +133,42 @@ mapGenerator:register2DPeaks('midgard',
v(200, 0, 100), v(200, 0, 100),
v(-300, 0, -200), v(-300, 0, -200),
})--]] })--]]
--[[
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', {x=250, y=250}, { mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', {x=250, y=250}, {
['#396fffff'] = {noise = { ['#396FFFFF'] = {noise = {
landscapeNoise = land1, landscapeNoise = land1,
tempNoise = climat2, tempNoise = climat2,
humidityNoise = climat2, humidityNoise = climat2,
} }
}, },
['3fff26ff'] = {noise = { ['#3FFF26FF'] = {noise = {
landscapeNoise = land2, landscapeNoise = land2,
tempNoise = climat2, tempNoise = climat2,
humidityNoise = climat2, humidityNoise = climat2,
} }
} }
}) })--]]
local N = 32
for x = -10, 10 do
for z = - 10, 10 do
local land
if math.random(0,1) == 0 then
land = land1
else
land = land2
end
print(x)
mapGenerator:register2DPeak('midgard', vector.new(x*N, 0, z*N), {
landscapeNoise = land,
tempNoise = climat2,
humidityNoise = climat2,
})
end
end
--[[
mapGenerator:registerCavern('midgard', 'cavern1', { mapGenerator:registerCavern('midgard', 'cavern1', {
minY = -48, minY = -48,
maxY = 0, maxY = 0,
@@ -163,7 +183,7 @@ mapGenerator:registerCavern('midgard', 'cavern1', {
persistence = 0.5, persistence = 0.5,
lacunarity = 2.0 lacunarity = 2.0
}, },
}) })--]]
-- --- Biomes --- -- --- Biomes ---