mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-12-29 12:20:41 +01:00
Fixups
This commit is contained in:
parent
e5b8f2b3b8
commit
f26fd1cccb
24
init.lua
24
init.lua
@ -5,31 +5,37 @@ if minetest.get_mapgen_setting("mg_name") ~= "singlenode" then
|
|||||||
minetest.log("warning", "[mapgen_rivers] Mapgen set to singlenode")
|
minetest.log("warning", "[mapgen_rivers] Mapgen set to singlenode")
|
||||||
end
|
end
|
||||||
|
|
||||||
dofile(modpath .. 'settings.lua')
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
dofile(modpath .. '/settings.lua')
|
||||||
|
|
||||||
local sfile = io.open(minetest.get_worldpath() .. '/river_data/size')
|
local sfile = io.open(minetest.get_worldpath() .. '/river_data/size')
|
||||||
if sfile then
|
if sfile then
|
||||||
sfile:close()
|
sfile:close()
|
||||||
else
|
else
|
||||||
dofile(modpath .. 'pregenerate.lua')
|
dofile(modpath .. '/pregenerate.lua')
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
end
|
end
|
||||||
|
|
||||||
mapgen_rivers.use_mapgen_thread = minetest.settings:get_bool("mapgen_rivers_use_mapgen_thread")
|
mapgen_rivers.use_mapgen_thread = minetest.settings:get_bool("mapgen_rivers_use_mapgen_thread")
|
||||||
mapgen_rivers.thread = 'main'
|
mapgen_rivers.thread = 'main'
|
||||||
if mapgen_rivers.use_mapgen_thread and minetest.register_mapgen_dofile then
|
if mapgen_rivers.use_mapgen_thread then
|
||||||
minetest.register_mapgen_dofile(modpath .. 'mapgen.lua')
|
if minetest.register_mapgen_dofile then
|
||||||
else
|
minetest.register_mapgen_dofile(modpath .. '/mapgen.lua')
|
||||||
minetest.log("warning", "[mapgen_rivers] Mapgen thread not available on this Minetest version.")
|
else
|
||||||
mapgen_rivers.use_mapgen_thread = false
|
minetest.log("warning", "[mapgen_rivers] Mapgen thread not available on this Minetest version.")
|
||||||
dofile(modpath .. 'mapgen.lua')
|
mapgen_rivers.use_mapgen_thread = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not mapgen_rivers.use_mapgen_thread then
|
||||||
|
dofile(modpath .. '/mapgen.lua')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Setup a metatable to load grid on request if not present
|
-- Setup a metatable to load grid on request if not present
|
||||||
local mt = {
|
local mt = {
|
||||||
__index = function(_, field)
|
__index = function(_, field)
|
||||||
if field == 'grid' then
|
if field == 'grid' then
|
||||||
dofile(modpath .. 'load_grid.lua')
|
dofile(modpath .. '/load_grid.lua')
|
||||||
return mapgen_rivers.grid
|
return mapgen_rivers.grid
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -12,7 +12,7 @@ else
|
|||||||
use_interactive_loader = not minetest.settings:get_bool("mapgen_rivers_load_all")
|
use_interactive_loader = not minetest.settings:get_bool("mapgen_rivers_load_all")
|
||||||
end
|
end
|
||||||
|
|
||||||
if mapgen_rivers.use_interactive_loader then
|
if use_interactive_loader then
|
||||||
local loader_mt = {
|
local loader_mt = {
|
||||||
__index = function(loader, i)
|
__index = function(loader, i)
|
||||||
local file = loader.file
|
local file = loader.file
|
||||||
@ -61,6 +61,7 @@ else
|
|||||||
|
|
||||||
for i=1, size do
|
for i=1, size do
|
||||||
local i0 = (i-1)*bytes+1
|
local i0 = (i-1)*bytes+1
|
||||||
|
local i1 = i*bytes
|
||||||
local elements = {data:byte(i0, i1)}
|
local elements = {data:byte(i0, i1)}
|
||||||
local n = sbyte(data, i0)
|
local n = sbyte(data, i0)
|
||||||
if signed and n >= 128 then
|
if signed and n >= 128 then
|
||||||
@ -85,7 +86,7 @@ else
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local sfile = io.open(world_data_path..'size', 'r')
|
local sfile = io.open(datapath..'size', 'r')
|
||||||
assert(sfile)
|
assert(sfile)
|
||||||
local X, Z = tonumber(sfile:read('*l')), tonumber(sfile:read('*l'))
|
local X, Z = tonumber(sfile:read('*l')), tonumber(sfile:read('*l'))
|
||||||
sfile:close()
|
sfile:close()
|
||||||
@ -96,7 +97,7 @@ end
|
|||||||
|
|
||||||
mapgen_rivers.grid = {
|
mapgen_rivers.grid = {
|
||||||
size = {x=X, y=Z},
|
size = {x=X, y=Z},
|
||||||
dem = load_map('dem', 2, true X*Z),
|
dem = load_map('dem', 2, true, X*Z),
|
||||||
lakes = load_map('lakes', 2, true, X*Z),
|
lakes = load_map('lakes', 2, true, X*Z),
|
||||||
dirs = load_map('dirs', 1, false, X*Z),
|
dirs = load_map('dirs', 1, false, X*Z),
|
||||||
rivers = load_map('rivers', 4, false, X*Z),
|
rivers = load_map('rivers', 4, false, X*Z),
|
||||||
|
@ -10,7 +10,7 @@ end
|
|||||||
|
|
||||||
local settings = mapgen_rivers.settings
|
local settings = mapgen_rivers.settings
|
||||||
|
|
||||||
local sea_level = tonumber(settings:get('sea_level'))
|
local sea_level = tonumber(minetest.get_mapgen_setting("water_level"))
|
||||||
local elevation_chill = tonumber(settings:get('elevation_chill'))
|
local elevation_chill = tonumber(settings:get('elevation_chill'))
|
||||||
local use_distort = settings:get_bool('distort')
|
local use_distort = settings:get_bool('distort')
|
||||||
local use_biomes = settings:get_bool('biomes')
|
local use_biomes = settings:get_bool('biomes')
|
||||||
@ -24,9 +24,9 @@ local noiseparams = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if use_biomes then
|
if use_biomes then
|
||||||
noiseparams.heat = minetest.get_mapgen_setting_noiseparams("np_heat")
|
noiseparams.heat = minetest.get_mapgen_setting_noiseparams("mg_biome_np_heat")
|
||||||
noiseparams.heat.offset = noiseparams.heat.offset + sea_level / elevation_chill
|
noiseparams.heat.offset = noiseparams.heat.offset + sea_level / elevation_chill
|
||||||
noiseparams.heat_blend = minetest.get_mapgen_setting_noiseparams("np_heat_blend")
|
noiseparams.heat_blend = minetest.get_mapgen_setting_noiseparams("mg_biome_np_heat_blend")
|
||||||
end
|
end
|
||||||
|
|
||||||
if use_biomegen_mod then
|
if use_biomegen_mod then
|
||||||
|
@ -39,7 +39,7 @@ local function get_temperature(x, y, z)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local glaciers = settings:get_bool('glaciers')
|
local glaciers = settings:get_bool('glaciers')
|
||||||
local glacier_factor = tonumber(settings:get('glacier_factor')
|
local glacier_factor = tonumber(settings:get('glacier_factor'))
|
||||||
|
|
||||||
local init = false
|
local init = false
|
||||||
|
|
||||||
|
@ -23,8 +23,10 @@ local niter = math.ceil(time/time_step)
|
|||||||
time_step = time / niter
|
time_step = time / niter
|
||||||
|
|
||||||
-- Setup the model
|
-- Setup the model
|
||||||
local grid = mapgen_rivers.grid
|
local size = {
|
||||||
local size = grid.size
|
x = tonumber(mapgen_rivers.settings:get("grid_x_size")),
|
||||||
|
y = tonumber(mapgen_rivers.settings:get("grid_z_size")),
|
||||||
|
}
|
||||||
|
|
||||||
local seed = tonumber(minetest.get_mapgen_setting("seed"))
|
local seed = tonumber(minetest.get_mapgen_setting("seed"))
|
||||||
np_base.seed = (np_base.seed or 0) + seed
|
np_base.seed = (np_base.seed or 0) + seed
|
||||||
@ -69,7 +71,7 @@ for i=1, size.x*size.y do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Write the results in the world directory
|
-- Write the results in the world directory
|
||||||
local datapath = minetest.get_worldpath .. "/river_data/"
|
local datapath = minetest.get_worldpath() .. "/river_data/"
|
||||||
minetest.mkdir(datapath)
|
minetest.mkdir(datapath)
|
||||||
|
|
||||||
local function write_map(filename, data, bytes)
|
local function write_map(filename, data, bytes)
|
||||||
@ -118,7 +120,7 @@ end
|
|||||||
|
|
||||||
if not use_interactive_loader then
|
if not use_interactive_loader then
|
||||||
mapgen_rivers.grid = {
|
mapgen_rivers.grid = {
|
||||||
size = {x=size_x, y=size_y},
|
size = size,
|
||||||
dem = model.dem,
|
dem = model.dem,
|
||||||
lakes = model.lakes,
|
lakes = model.lakes,
|
||||||
dirs = model.dirs,
|
dirs = model.dirs,
|
||||||
|
@ -43,7 +43,7 @@ local function verify_setting(name, dtype, default)
|
|||||||
v = mtsettings:get(mtname)
|
v = mtsettings:get(mtname)
|
||||||
end
|
end
|
||||||
settings:set_bool(name, v)
|
settings:set_bool(name, v)
|
||||||
elseif dtype = "noise" then
|
elseif dtype == "noise" then
|
||||||
if mthas then
|
if mthas then
|
||||||
v = mtsettings:get_np_group(mtname)
|
v = mtsettings:get_np_group(mtname)
|
||||||
end
|
end
|
||||||
|
@ -123,7 +123,7 @@ end
|
|||||||
|
|
||||||
local modpath = ""
|
local modpath = ""
|
||||||
if minetest then
|
if minetest then
|
||||||
modpath = minetest.get_modpath(minetest.get_current_modname()) .. "terrainlib_lua/"
|
modpath = minetest.get_modpath(minetest.get_current_modname()) .. "/terrainlib_lua/"
|
||||||
end
|
end
|
||||||
|
|
||||||
local rivermapper = dofile(modpath .. "rivermapper.lua")
|
local rivermapper = dofile(modpath .. "rivermapper.lua")
|
||||||
|
Loading…
Reference in New Issue
Block a user