Add random seed button

This commit is contained in:
Wuzzy 2022-04-15 22:18:53 +02:00
parent 437bfc81c5
commit 2595c48ab4

View File

@ -497,6 +497,7 @@ local show_formspec = function(player, noiseparams, profile_id)
field[0.25,1.75;2,0.75;offset;]]..F(S("Offset"))..[[;]]..offset..[[]
field[3.25,1.75;2,0.75;scale;]]..F(S("Scale"))..[[;]]..scale..[[]
field[6.25,1.75;2,0.75;seed;]]..F(S("Seed"))..[[;]]..seed..[[]
image_button[8.35,1.75;0.75,0.75;perlin_explorer_seeder.png;set_random_seed;]
field[0.25,3.0;2,0.75;spread_x;]]..F(S("X Spread"))..[[;]]..sx..[[]
field[3.25,3.0;2,0.75;spread_y;]]..F(S("Y Spread"))..[[;]]..sy..[[]
field[6.25,3.0;2,0.75;spread_z;]]..F(S("Z Spread"))..[[;]]..sz..[[]
@ -505,6 +506,8 @@ local show_formspec = function(player, noiseparams, profile_id)
field[6.25,4.25;2,0.75;lacunarity;]]..F(S("Lacunarity"))..[[;]]..lacunarity..[[]
checkbox[0.5,5.25;eased;]]..F(S("eased"))..[[;]]..eased..[[]
checkbox[3.5,5.25;absvalue;]]..F(S("absvalue"))..[[;]]..absvalue..[[]
tooltip[set_random_seed;]]..F(S("Random seed"))..[[]
container_end[]
container[0.25,6.0]
@ -642,7 +645,14 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
minetest.log("action", "[perlin_explorer] Perlin noise profile "..new_profile.." added!")
show_formspec(player, noiseparams, new_profile)
return
elseif fields.set_random_seed then
-- Randomize seed
local profile = tonumber(fields.np_profiles)
noiseparams.seed = math.random(0, 2^32-1)
show_formspec(player, noiseparams, profile)
return
end
if not (dimensions and sidelen and size and value_min and value_max) then
return
end