mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2025-02-20 14:00:32 +01:00
Replace table settings by the mod's Settings object (to be completed)
This commit is contained in:
parent
11e6e72324
commit
6fa1852277
@ -1,13 +1,14 @@
|
||||
-- Recreate mod table if we are in a separate environment
|
||||
if not minetest.global_exists("mapgen_rivers") then
|
||||
mapgen_rivers = {use_mapgen_thread=true, thread='mapgen'}
|
||||
mapgen_rivers.settings = Settings(minetest.get_worldpath() .. '/mapgen_rivers.conf')
|
||||
end
|
||||
|
||||
if not mapgen_rivers.grid then
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()) .. '/load_grid.lua')
|
||||
end
|
||||
|
||||
local settings = Settings(minetest.get_worldpath() .. '/mapgen_rivers.conf')
|
||||
local settings = mapgen_rivers.settings
|
||||
|
||||
local sea_level = tonumber(settings:get('sea_level'))
|
||||
local elevation_chill = tonumber(settings:get('elevation_chill'))
|
||||
|
20
polygons.lua
20
polygons.lua
@ -5,12 +5,14 @@ local function index(x, z)
|
||||
return z*X+x+1
|
||||
end
|
||||
|
||||
local blocksize = mapgen_rivers.settings.blocksize
|
||||
local min_catchment = mapgen_rivers.settings.min_catchment
|
||||
local max_catchment = mapgen_rivers.settings.max_catchment
|
||||
local settings = mapgen_rivers.settings
|
||||
|
||||
local blocksize = tonumber(settings:get('blocksize'))
|
||||
local min_catchment = tonumber(settings:get('min_catchment'))
|
||||
local max_catchment = tonumber(settings:get('max_catchment'))
|
||||
|
||||
local map_offset = {x=0, z=0}
|
||||
if mapgen_rivers.settings.center then
|
||||
if settings:get_bool('center') then
|
||||
map_offset.x = blocksize*X/2
|
||||
map_offset.z = blocksize*Z/2
|
||||
end
|
||||
@ -18,8 +20,8 @@ end
|
||||
-- Localize for performance
|
||||
local floor, ceil, min, max, abs = math.floor, math.ceil, math.min, math.max, math.abs
|
||||
|
||||
local min_catchment = mapgen_rivers.settings.min_catchment / (blocksize*blocksize)
|
||||
local wpower = mapgen_rivers.settings.river_widening_power
|
||||
min_catchment = min_catchment / (blocksize*blocksize)
|
||||
local wpower = settings:get('river_widening_power')
|
||||
local wfactor = 1/(2*blocksize * min_catchment^wpower)
|
||||
local function river_width(flow)
|
||||
flow = abs(flow)
|
||||
@ -31,14 +33,14 @@ local function river_width(flow)
|
||||
end
|
||||
|
||||
local noise_heat -- Need a large-scale noise here so no heat blend
|
||||
local elevation_chill = mapgen_rivers.settings.elevation_chill
|
||||
local elevation_chill = settings:get_bool('elevation_chill')
|
||||
local function get_temperature(x, y, z)
|
||||
local pos = {x=x, y=z}
|
||||
return noise_heat:get2d(pos) - y*elevation_chill
|
||||
end
|
||||
|
||||
local glaciers = mapgen_rivers.settings.glaciers
|
||||
local glacier_factor = mapgen_rivers.settings.glacier_factor
|
||||
local glaciers = settings:get_bool('glaciers')
|
||||
local glacier_factor = tonumber(settings:get('glacier_factor')
|
||||
|
||||
local init = false
|
||||
|
||||
|
@ -2,6 +2,7 @@ local mtsettings = minetest.settings
|
||||
local mgrsettings = Settings(minetest.get_worldpath() .. '/mapgen_rivers.conf')
|
||||
|
||||
mapgen_rivers.version = "1.0.2"
|
||||
mapgen_rivers.settings = settings
|
||||
|
||||
local previous_version_mt = mtsettings:get("mapgen_rivers_version") or "0.0"
|
||||
local previous_version_mgr = mgrsettings:get("version") or "0.0"
|
||||
|
Loading…
x
Reference in New Issue
Block a user