allow configuring the mapgen size, rarity and smooth without rejoining, which is actually a bad idea because of chunk corners

This commit is contained in:
HybridDog
2015-11-22 01:21:21 +01:00
parent 346a263761
commit afc578cb16
7 changed files with 164 additions and 47 deletions

View File

@ -23,20 +23,38 @@ end
local rarity = snow.mapgen_rarity
local size = snow.mapgen_size
local nosmooth_rarity = 1-rarity/50
local perlin_scale = size*100/rarity
mg.perlin_scale = perlin_scale
local smooth_rarity_max, smooth_rarity_min, smooth_rarity_dif
local smooth = snow.smooth_biomes
if smooth then
local smooth_trans_size = 4 --snow.smooth_trans_size
mg.smooth_rarity_max = upper_rarity(nosmooth_rarity+smooth_trans_size*2/perlin_scale)
mg.smooth_rarity_min = upper_rarity(nosmooth_rarity-smooth_trans_size/perlin_scale)
mg.smooth_rarity_dif = mg.smooth_rarity_max-mg.smooth_rarity_min
local nosmooth_rarity, perlin_scale
local function calc_values()
nosmooth_rarity = 1-rarity/50
perlin_scale = size*100/rarity
mg.perlin_scale = perlin_scale
local smooth_rarity_max, smooth_rarity_min, smooth_rarity_dif
if smooth then
local smooth_trans_size = 4 --snow.smooth_trans_size
mg.smooth_rarity_max = upper_rarity(nosmooth_rarity+smooth_trans_size*2/perlin_scale)
mg.smooth_rarity_min = upper_rarity(nosmooth_rarity-smooth_trans_size/perlin_scale)
mg.smooth_rarity_dif = mg.smooth_rarity_max-mg.smooth_rarity_min
end
nosmooth_rarity = upper_rarity(nosmooth_rarity)
mg.nosmooth_rarity = nosmooth_rarity
end
nosmooth_rarity = upper_rarity(nosmooth_rarity)
mg.nosmooth_rarity = nosmooth_rarity
calc_values()
snow.register_on_configuring(function(name, v)
if name == "mapgen_rarity" then
rarity = v
elseif name == "mapgen_size" then
size = v
elseif name == "smooth_biomes" then
smooth = v
else
return
end
-- TODO: if e.g. size and rarity get changed at once, don't calculate the values more times
calc_values()
end)
--Identify the mapgen.