Add seed randomizer (for convenience)
This commit is contained in:
parent
5b40796439
commit
437bfc81c5
42
init.lua
42
init.lua
@ -75,6 +75,13 @@ local sidelen_pos = function(pos, sidelen)
|
||||
return newpos
|
||||
end
|
||||
|
||||
-- Sets the currently active Perlin noise.
|
||||
-- * noiseparams: NoiseParams table (see Minetest's Lua API documentation)
|
||||
local set_perlin_noise = function(noiseparams)
|
||||
current_perlin.noise = PerlinNoise(noiseparams)
|
||||
current_perlin.noiseparams = noiseparams
|
||||
end
|
||||
|
||||
-- Test nodes to generate a map based on a perlin noise
|
||||
local paramtype2
|
||||
if COLORIZE_NODES then
|
||||
@ -139,6 +146,34 @@ minetest.register_tool("perlin_explorer:getter", {
|
||||
end
|
||||
end,
|
||||
})
|
||||
minetest.register_tool("perlin_explorer:seeder", {
|
||||
description = S("Random Perlin seed setter"),
|
||||
_tt_help = S("Set a random Perlin seed for the current Perlin noise params"),
|
||||
inventory_image = "perlin_explorer_seeder.png",
|
||||
wield_image = "perlin_explorer_seeder.png",
|
||||
groups = { disable_repair = 1 },
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if not user then
|
||||
return
|
||||
end
|
||||
local privs = minetest.get_player_privs(user:get_player_name())
|
||||
if not privs.server then
|
||||
minetest.chat_send_player(user:get_player_name(), S("Insufficient privileges! You need the @1 privilege to use this tool.", "server"))
|
||||
return
|
||||
end
|
||||
if current_perlin.noise then
|
||||
local noiseparams = table.copy(current_perlin.noiseparams)
|
||||
noiseparams.seed = math.random(0, 2^32-1)
|
||||
set_perlin_noise(noiseparams)
|
||||
current_perlin.loaded_areas = {}
|
||||
local msg = S("New random seed set!")
|
||||
minetest.chat_send_player(user:get_player_name(), msg)
|
||||
else
|
||||
local msg = S("No Perlin noise set. Set one first!")
|
||||
minetest.chat_send_player(user:get_player_name(), msg)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local CONTENT_TEST_NODE = minetest.get_content_id("perlin_explorer:node")
|
||||
local CONTENT_TEST_NODE_NEGATIVE = minetest.get_content_id("perlin_explorer:node_negative")
|
||||
@ -285,13 +320,6 @@ local create_perlin = function(pos, options)
|
||||
end
|
||||
end
|
||||
|
||||
-- Sets the currently active Perlin noise.
|
||||
-- * noiseparams: NoiseParams table (see Minetest's Lua API documentation)
|
||||
local set_perlin_noise = function(noiseparams)
|
||||
current_perlin.noise = PerlinNoise(noiseparams)
|
||||
current_perlin.noiseparams = noiseparams
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("perlin_set_options", {
|
||||
privs = { server = true },
|
||||
description = S("Set Perlin options"),
|
||||
|
BIN
textures/perlin_explorer_seeder.png
Normal file
BIN
textures/perlin_explorer_seeder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 972 B |
Loading…
x
Reference in New Issue
Block a user