Fix crash if call perlin_set_noise
This commit is contained in:
parent
1a79f6aaae
commit
f9c206409b
20
init.lua
20
init.lua
@ -829,6 +829,16 @@ local fix_sidelen = function(sidelen)
|
||||
return math.max(1, math.floor(sidelen))
|
||||
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_tool("perlin_explorer:seeder", {
|
||||
description = S("Random Perlin seed setter"),
|
||||
_tt_help = S("Punch: Set a random seed for the current Perlin noise params").."\n"..
|
||||
@ -1332,16 +1342,6 @@ local show_noise_formspec = function(player, noiseparams, profile_id)
|
||||
minetest.show_formspec(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)
|
||||
-- Require 'server' priv
|
||||
local privs = minetest.get_player_privs(player:get_player_name())
|
||||
|
Loading…
x
Reference in New Issue
Block a user