MapGen: move ff2luat.lua Api->MapGen

This commit is contained in:
Van
2026-01-12 18:31:06 +03:00
parent 84295c56c4
commit 8640e55415
4 changed files with 6 additions and 9 deletions

View File

@@ -3,5 +3,4 @@ Api = {}
local modInfo = Mod.getInfo('smc__api__api_loader')
local require = modInfo.require
require('Api.ff2lua')
require('Api.globalStep')

View File

@@ -41,6 +41,8 @@ local Triangulation = require('MapGen.Triangulation')
---@type MapGen.Cavern
local Cavern = require('MapGen.Cavern')
local ff2luat = require('MapGen.ff2luat')
---@class MapGen
---@field layersByName table<string, MapGen.Layer>
---@field layersList MapGen.Layer[]
@@ -250,7 +252,7 @@ end
---@param groups? table<string, number>
function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category, groups)
local modPath = core.get_modpath(core.get_current_modname())
local peaks = Api.ff2luat(modPath .. '/textures/maps/' .. map)
local peaks = ff2luat(modPath .. '/textures/maps/' .. map)
local mapSize = peaks.size
peaks.size = nil
@@ -901,10 +903,6 @@ function MapGen:run()
self:initLayersTriangultaion()
MapGen.isRunning = true
for _, peak in ipairs(self.layersList[1].peaksList["landscape"]) do
print(tostring(peak))
end
end
return MapGen

View File

@@ -53,7 +53,7 @@ end
---@param filepath string image in farbfeld format
---@param backgroundColor string? ColorString, will be ignored while processing image. Default: `#000000FF`
---@return ColoredDotsTable
function Api.ff2luat(filepath, backgroundColor)
local function ff2luat(filepath, backgroundColor)
local file = io.open(filepath, 'rb')
if not file then error('Can\'t open farbfeld image: ' .. dump(filepath)) end
local ff = file:read('*a') -- binary!
@@ -97,3 +97,5 @@ function Api.ff2luat(filepath, backgroundColor)
return dots
end
return ff2luat

View File

@@ -37,8 +37,6 @@ dofile(core.get_modpath('smc__api__table')..'/init.lua')
-- TODO: пока что закоментировано, поскольку вызывает ошибку из-за global_step
-- Api loader
-- 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
local mapGenerator = dofile(core.get_modpath('smc__core__map_generator')..'/src/mapGenerator.lua')