From 11c4e50150bb7bc777cf81805e8f14243e38b42a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 20 Apr 2022 17:03:56 +0200 Subject: [PATCH] Add setting to set default noiseparams --- init.lua | 17 +++++++++++++---- settingtypes.txt | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index ccc5da7..36bf2de 100644 --- a/init.lua +++ b/init.lua @@ -98,9 +98,16 @@ local default_noiseparams = { octaves = 2, persistence = 0.5, lacunarity = 2.0, - flags = "defaults,noabsvalue", + flags = "defaults", } +-- Get default noise params by setting (if available) +local np_by_setting = minetest.settings:get_np_group("perlin_explorer_default_noiseparams") +if np_by_setting then + default_noiseparams = np_by_setting + minetest.log("info", "[perlin_explorer] default noiseparams read from setting") +end + -- Holds the currently used Perlin noise local current_perlin = {} -- holds the current PerlinNoise object @@ -1620,10 +1627,12 @@ end) minetest.register_on_joinplayer(function(player) local name = player:get_player_name() + local flags = default_noiseparams.flags + local flags_table = parse_flags_string(flags) formspec_states[name] = { - defaults = true, - eased = false, - absvalue = false, + defaults = flags_table.defaults, + eased = flags_table.eased, + absvalue = flags_table.absvalue, sidelen = 1, noiseparams = table.copy(default_noiseparams), } diff --git a/settingtypes.txt b/settingtypes.txt index 20d4c77..15889c1 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,3 +1,6 @@ +# The default noise parameters that this mod will start with. +perlin_explorer_default_noiseparams (Default noise parameters) noise_params_3d 0, 1, (10, 10, 10), 0, 2, 0.5, 2.0, defaults + # Number of available colors to use per node color palette, # ignoring the special “extreme” colors (which are always used). # High values lead to a smoother color gradient but also might