Globalize modpath and worldpath

This commit is contained in:
Gaël C 2021-06-03 19:21:45 +02:00
parent 0427b42d17
commit 19efeaaff6
5 changed files with 15 additions and 10 deletions

View File

@ -1,4 +1,4 @@
local modpath = minetest.get_modpath(minetest.get_current_modname()) .. '/'
local modpath = mapgen_rivers.modpath
local make_polygons = dofile(modpath .. 'polygons.lua')
local transform_quadri = dofile(modpath .. 'geometry.lua')

View File

@ -1,6 +1,8 @@
mapgen_rivers = {}
local modpath = minetest.get_modpath(minetest.get_current_modname()) .. '/'
mapgen_rivers.modpath = modpath
mapgen_rivers.world_data_path = minetest.get_worldpath() .. '/river_data'
dofile(modpath .. 'settings.lua')

View File

@ -1,4 +1,4 @@
local worldpath = minetest.get_worldpath() .. "/river_data/"
local worldpath = minetest.world_data_path
local function load_map(filename, bytes, signed, size)
local file = io.open(worldpath .. filename, 'rb')

View File

@ -1,10 +1,10 @@
local modpath = minetest.get_modpath(minetest.get_current_modname()) .. '/'
local modpath = mapgen_rivers.modpath
local mod_data_path = modpath .. 'river_data/'
if not io.open(mod_data_path .. 'size', 'r') then
mod_data_path = modpath .. 'demo_data/'
end
local world_data_path = minetest.get_worldpath() .. '/river_data/'
local world_data_path = minetest.world_data_path
minetest.mkdir(world_data_path)
local load_map = dofile(modpath .. 'load.lua')

View File

@ -108,14 +108,17 @@ local function diffuse(model, time)
-- TODO Test this
end
local rivermapper, gaussian
local modpath = ""
if minetest then
rivermapper = dofile(minetest.get_modpath(minetest.get_current_modname()) .. '/terrainlib_lua/rivermapper.lua')
gaussian = dofile(minetest.get_modpath(minetest.get_current_modname()) .. '/terrainlib_lua/gaussian.lua')
if minetest.global_exists(mapgen_rivers) then
modpath = mapgen_rivers.modpath .. "terrainlib_lua/"
else
rivermapper = dofile('rivermapper.lua')
gaussian = dofile('gaussian.lua')
modpath = minetest.get_modpath(minetest.get_current_modname()) .. "terrainlib_lua/"
end
end
local rivermapper = dofile(modpath .. "rivermapper.lua")
local gaussian = dofile(modpath .. "gaussian.lua")
local function flow(model)
model.dirs, model.lakes = rivermapper.flow_routing(model.dem, model.dirs, model.lakes, 'semirandom')