Do some simple noiseparams fixes
This commit is contained in:
parent
4209e4788d
commit
cd34499c3c
17
init.lua
17
init.lua
@ -591,7 +591,7 @@ minetest.register_chatcommand("perlin_set_noise", {
|
||||
if not octaves or not offset or not sx or not sy or not sz or not persistence or not lacunarity or not seed then
|
||||
return false, S("Invalid parameter type.")
|
||||
end
|
||||
set_perlin_noise({
|
||||
local noiseparams = {
|
||||
octaves = octaves,
|
||||
offset = offset,
|
||||
scale = scale,
|
||||
@ -600,7 +600,9 @@ minetest.register_chatcommand("perlin_set_noise", {
|
||||
lacunarity = lacunarity,
|
||||
seed = seed,
|
||||
flags = flags,
|
||||
})
|
||||
}
|
||||
noiseparams = fix_noiseparams(noiseparams)
|
||||
set_perlin_noise(noiseparams)
|
||||
loaded_areas = {}
|
||||
return true, S("Active Perlin noise parameters set!")
|
||||
end,
|
||||
@ -829,6 +831,16 @@ local show_noise_formspec = function(player, noiseparams, profile_id)
|
||||
minetest.show_formspec(player:get_player_name(), "perlin_explorer:creator", form)
|
||||
end
|
||||
|
||||
-- Fix some errors in the noiseparams
|
||||
local fix_noiseparams = function(noiseparams)
|
||||
noiseparams.octaves = math.floor(math.max(1, noiseparams.octaves))
|
||||
noiseparams.lacunarity = math.max(1.0, noiseparams.lacunarity)
|
||||
noiseparams.spread.x = math.floor(math.max(1, noiseparams.spread.x))
|
||||
noiseparams.spread.y = math.floor(math.max(1, noiseparams.spread.y))
|
||||
noiseparams.spread.z = math.floor(math.max(1, noiseparams.spread.z))
|
||||
return noiseparams
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname == "perlin_explorer:analyze" and fields.done then
|
||||
local noiseparams = formspec_states[player:get_player_name()].noiseparams
|
||||
@ -917,6 +929,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
lacunarity = lacunarity,
|
||||
flags = build_flags_string(eased, absvalue),
|
||||
}
|
||||
noiseparams = fix_noiseparams(noiseparams)
|
||||
-- Open analyze window
|
||||
if do_analyze then
|
||||
formspec_states[player:get_player_name()].noiseparams = noiseparams
|
||||
|
Loading…
x
Reference in New Issue
Block a user