From f52734c82283b1f14221903baf6c1003390acbc2 Mon Sep 17 00:00:00 2001 From: birdlover32767 <162155761+birdlover32767@users.noreply.github.com> Date: Tue, 2 Sep 2025 12:07:50 +0300 Subject: [PATCH 1/6] Add tooltips to mapgen flags --- .../settings/dlg_change_mapgen_flags.lua | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/builtin/common/settings/dlg_change_mapgen_flags.lua b/builtin/common/settings/dlg_change_mapgen_flags.lua index de96c75e33..505329c408 100644 --- a/builtin/common/settings/dlg_change_mapgen_flags.lua +++ b/builtin/common/settings/dlg_change_mapgen_flags.lua @@ -46,33 +46,42 @@ local function get_formspec(dialogdata) end local fields = {} - local function add_field(x, name, label, value) + local function add_field(x, name, label, value, tt) fields[#fields + 1] = ("field[%f,%f;3.3,1;%s;%s;%s]"):format( x, height, name, label, core.formspec_escape(value or "") ) + if tt then + fields[#fields + 1] = ("tooltip[%s;%s]"):format(name, tt) + end end -- First row height = height + 0.3 - add_field(0.3, "te_offset", fgettext("Offset"), t[1]) - add_field(3.6, "te_scale", fgettext("Scale"), t[2]) - add_field(6.9, "te_seed", fgettext("Seed"), t[6]) + add_field(0.3, "te_offset", fgettext("Offset"), t[1], fgettext("This value offsets the final noise.")) + add_field(3.6, "te_scale", fgettext("Scale"), t[2], fgettext("This value multiplies the noise before the offset is added.")) + add_field(6.9, "te_seed", fgettext("Seed"), t[6], fgettext("This value acts as a random seed for the noise. Every value will result in a different, random result.")) height = height + 1.1 -- Second row - add_field(0.3, "te_spreadx", fgettext("X spread"), t[3]) + add_field(0.3, "te_spreadx", fgettext("X spread"), t[3], fgettext("This value \"scales\" the noise in the X axis by this value.")) if dimension == 3 then - add_field(3.6, "te_spready", fgettext("Y spread"), t[4]) + add_field(3.6, "te_spready", fgettext("Y spread"), t[4], fgettext("This value \"scales\" the noise in the Y axis by this value.")) else fields[#fields + 1] = "label[4," .. height - 0.2 .. ";" .. fgettext("2D Noise") .. "]" end - add_field(6.9, "te_spreadz", fgettext("Z spread"), t[5]) + add_field(6.9, "te_spreadz", fgettext("Z spread"), t[5], fgettext("This value \"scales\" the noise in the Z axis by this value.")) height = height + 1.1 -- Third row - add_field(0.3, "te_octaves", fgettext("Octaves"), t[7]) - add_field(3.6, "te_persist", fgettext("Persistence"), t[8]) - add_field(6.9, "te_lacun", fgettext("Lacunarity"), t[9]) + add_field(0.3, "te_octaves", fgettext("Octaves"), t[7], fgettext([[This value controls how many octaves the noise will have. +An octave is a simple noise generator. Its scale and amplitude will be multiplied based on the Persistence and Lacunarity settings. +Finally, all of the octaves will be added to generate this noise.]])) + add_field(3.6, "te_persist", fgettext("Persistence"), t[8], fgettext([[This value multiplies an octave's amplitude by the previous octave multiplied by this value. + +Example: If the persistence was 0.5, the 1st octave would be scaled by 1, the 2nd would be by 0.5, the 3rd would be by 0.25, etc.]])) + add_field(6.9, "te_lacun", fgettext("Lacunarity"), t[9], fgettext([[This value multiplies an octave's scale by the previous octave multiplied by this value. + +Example: If the lacunarity was 0.5, the 1st octave would be scaled by 1, the 2nd would be by 0.5, the 3rd would be by 0.25, etc.]])) height = height + 1.1 @@ -95,6 +104,10 @@ local function get_formspec(dialogdata) for noise settings in the settings menu. ]] .. fgettext("defaults") .. ";" -- defaults .. tostring(flags["defaults"] == true) .. "]" -- to get false if nil + .. "tooltip[cb_defaults;" .. fgettext([[This flag overrides the eased flag based on the noise map type. + +2D noise will make eased on. +3D noise will make eased off.]]) .. "]" .. "checkbox[5," .. height - 0.6 .. ";cb_eased;" --[[~ "eased" is a noise parameter flag. It is used to make the map smoother and @@ -102,6 +115,10 @@ local function get_formspec(dialogdata) the settings menu. ]] .. fgettext("eased") .. ";" -- eased .. tostring(flags["eased"] == true) .. "]" + .. "tooltip[cb_eased;" .. fgettext([[This flag maps noise gradient values onto a quintic S-curve before performing interpolation. +This results in smooth noise instead of gridlike noise. + +Making 3D noise eased is not recommended because it significantly increases the computation load.]]) .. "]" .. "checkbox[5," .. height - 0.15 .. ";cb_absvalue;" --[[~ "absvalue" is a noise parameter flag. It is short for "absolute value". @@ -109,6 +126,8 @@ local function get_formspec(dialogdata) the settings menu. ]] .. fgettext("absvalue") .. ";" -- absvalue .. tostring(flags["absvalue"] == true) .. "]" + .. "tooltip[cb_absvalue;" .. fgettext([[This flag takes the absolute value of each octave while adding them together. +This results in "spiky" noise.]]) .. "]" height = height + 1 From 1ef995ed825a9bb3274697afc79bdce9dd9aab1b Mon Sep 17 00:00:00 2001 From: birdlover32767 <162155761+birdlover32767@users.noreply.github.com> Date: Tue, 2 Sep 2025 15:20:32 +0300 Subject: [PATCH 2/6] Fix luacheck warning --- .../settings/dlg_change_mapgen_flags.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/builtin/common/settings/dlg_change_mapgen_flags.lua b/builtin/common/settings/dlg_change_mapgen_flags.lua index 505329c408..f015363ddc 100644 --- a/builtin/common/settings/dlg_change_mapgen_flags.lua +++ b/builtin/common/settings/dlg_change_mapgen_flags.lua @@ -73,13 +73,16 @@ local function get_formspec(dialogdata) height = height + 1.1 -- Third row - add_field(0.3, "te_octaves", fgettext("Octaves"), t[7], fgettext([[This value controls how many octaves the noise will have. + add_field(0.3, "te_octaves", fgettext("Octaves"), t[7], fgettext( +[[This value controls how many octaves the noise will have. An octave is a simple noise generator. Its scale and amplitude will be multiplied based on the Persistence and Lacunarity settings. Finally, all of the octaves will be added to generate this noise.]])) - add_field(3.6, "te_persist", fgettext("Persistence"), t[8], fgettext([[This value multiplies an octave's amplitude by the previous octave multiplied by this value. + add_field(3.6, "te_persist", fgettext("Persistence"), t[8], fgettext( +[[This value multiplies an octave's amplitude by the previous octave multiplied by this value. Example: If the persistence was 0.5, the 1st octave would be scaled by 1, the 2nd would be by 0.5, the 3rd would be by 0.25, etc.]])) - add_field(6.9, "te_lacun", fgettext("Lacunarity"), t[9], fgettext([[This value multiplies an octave's scale by the previous octave multiplied by this value. + add_field(6.9, "te_lacun", fgettext("Lacunarity"), t[9], fgettext( +[[This value multiplies an octave's scale by the previous octave multiplied by this value. Example: If the lacunarity was 0.5, the 1st octave would be scaled by 1, the 2nd would be by 0.5, the 3rd would be by 0.25, etc.]])) height = height + 1.1 @@ -104,7 +107,8 @@ Example: If the lacunarity was 0.5, the 1st octave would be scaled by 1, the 2nd for noise settings in the settings menu. ]] .. fgettext("defaults") .. ";" -- defaults .. tostring(flags["defaults"] == true) .. "]" -- to get false if nil - .. "tooltip[cb_defaults;" .. fgettext([[This flag overrides the eased flag based on the noise map type. + .. "tooltip[cb_defaults;" .. fgettext( +[[This flag overrides the eased flag based on the noise map type. 2D noise will make eased on. 3D noise will make eased off.]]) .. "]" @@ -115,7 +119,8 @@ Example: If the lacunarity was 0.5, the 1st octave would be scaled by 1, the 2nd the settings menu. ]] .. fgettext("eased") .. ";" -- eased .. tostring(flags["eased"] == true) .. "]" - .. "tooltip[cb_eased;" .. fgettext([[This flag maps noise gradient values onto a quintic S-curve before performing interpolation. + .. "tooltip[cb_eased;" .. fgettext( +[[This flag maps noise gradient values onto a quintic S-curve before performing interpolation. This results in smooth noise instead of gridlike noise. Making 3D noise eased is not recommended because it significantly increases the computation load.]]) .. "]" @@ -126,7 +131,8 @@ Making 3D noise eased is not recommended because it significantly increases the the settings menu. ]] .. fgettext("absvalue") .. ";" -- absvalue .. tostring(flags["absvalue"] == true) .. "]" - .. "tooltip[cb_absvalue;" .. fgettext([[This flag takes the absolute value of each octave while adding them together. + .. "tooltip[cb_absvalue;" .. fgettext( +[[This flag takes the absolute value of each octave while adding them together. This results in "spiky" noise.]]) .. "]" height = height + 1 From dfe07e7eeee9d0736d9297e6a83ef80e8577fbc4 Mon Sep 17 00:00:00 2001 From: birdlover32767 <162155761+birdlover32767@users.noreply.github.com> Date: Wed, 3 Sep 2025 11:26:26 +0300 Subject: [PATCH 3/6] Change tooltips and remove old code --- .../settings/dlg_change_mapgen_flags.lua | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/builtin/common/settings/dlg_change_mapgen_flags.lua b/builtin/common/settings/dlg_change_mapgen_flags.lua index f015363ddc..17bfaf8b3a 100644 --- a/builtin/common/settings/dlg_change_mapgen_flags.lua +++ b/builtin/common/settings/dlg_change_mapgen_flags.lua @@ -46,45 +46,50 @@ local function get_formspec(dialogdata) end local fields = {} - local function add_field(x, name, label, value, tt) + local function add_field(x, name, label, value, tooltips) fields[#fields + 1] = ("field[%f,%f;3.3,1;%s;%s;%s]"):format( x, height, name, label, core.formspec_escape(value or "") ) - if tt then - fields[#fields + 1] = ("tooltip[%s;%s]"):format(name, tt) + if tooltips then + fields[#fields + 1] = ("tooltip[%s;%s]"):format(name, table.concat(tooltips, "\n")) end end -- First row height = height + 0.3 - add_field(0.3, "te_offset", fgettext("Offset"), t[1], fgettext("This value offsets the final noise.")) - add_field(3.6, "te_scale", fgettext("Scale"), t[2], fgettext("This value multiplies the noise before the offset is added.")) - add_field(6.9, "te_seed", fgettext("Seed"), t[6], fgettext("This value acts as a random seed for the noise. Every value will result in a different, random result.")) + add_field(0.3, "te_offset", fgettext("Offset"), t[1], {fgettext("This value offsets the final noise.")}) + add_field(3.6, "te_scale", fgettext("Scale"), t[2], {fgettext("This value multiplied with the noise before the offset is added.")}) + add_field(6.9, "te_seed", fgettext("Seed"), t[6], { + fgettext("This value acts as a random seed for the noise. The same seed results in the same noise.")}) height = height + 1.1 -- Second row - add_field(0.3, "te_spreadx", fgettext("X spread"), t[3], fgettext("This value \"scales\" the noise in the X axis by this value.")) + add_field(0.3, "te_spreadx", fgettext("X spread"), t[3], { + fgettext("This value scales the noise in the X axis by this value."), + fgettext("This is also the scale of the largest structures in the X direction of the noise.")}) if dimension == 3 then - add_field(3.6, "te_spready", fgettext("Y spread"), t[4], fgettext("This value \"scales\" the noise in the Y axis by this value.")) + add_field(3.6, "te_spready", fgettext("Y spread"), t[4], { + fgettext("This value scales the noise in the Y axis by this value."), + fgettext("This is also the scale of the largest structures in the Y direction of the noise.")}) else fields[#fields + 1] = "label[4," .. height - 0.2 .. ";" .. fgettext("2D Noise") .. "]" end - add_field(6.9, "te_spreadz", fgettext("Z spread"), t[5], fgettext("This value \"scales\" the noise in the Z axis by this value.")) + add_field(6.9, "te_spreadz", fgettext("Z spread"), t[5], { + fgettext("This value scales the noise in the Z axis by this value."), + fgettext("This is also the scale of the largest structures in the Z direction of the noise.")}) height = height + 1.1 -- Third row - add_field(0.3, "te_octaves", fgettext("Octaves"), t[7], fgettext( -[[This value controls how many octaves the noise will have. -An octave is a simple noise generator. Its scale and amplitude will be multiplied based on the Persistence and Lacunarity settings. -Finally, all of the octaves will be added to generate this noise.]])) - add_field(3.6, "te_persist", fgettext("Persistence"), t[8], fgettext( -[[This value multiplies an octave's amplitude by the previous octave multiplied by this value. - -Example: If the persistence was 0.5, the 1st octave would be scaled by 1, the 2nd would be by 0.5, the 3rd would be by 0.25, etc.]])) - add_field(6.9, "te_lacun", fgettext("Lacunarity"), t[9], fgettext( -[[This value multiplies an octave's scale by the previous octave multiplied by this value. - -Example: If the lacunarity was 0.5, the 1st octave would be scaled by 1, the 2nd would be by 0.5, the 3rd would be by 0.25, etc.]])) + add_field(0.3, "te_octaves", fgettext("Octaves"), t[7], { + fgettext("This value controls how many octaves the noise will have."), + fgettext("An octave is a simple noise generator. Its scale and amplitude will be multiplied based on the Persistence and Lacunarity settings."), + fgettext("Finally, all of the octaves will be added to generate this noise.")}) + add_field(3.6, "te_persist", fgettext("Persistence"), t[8], { + fgettext("This value multiplies every octave's amplitude by persistence^i where i is the place of the octave."), + fgettext("Example: If the persistence was 0.5, the 1st octave would be amplified by 1, the 2nd would be by 0.5, the 3rd would be by 0.25, etc.")}) + add_field(6.9, "te_lacun", fgettext("Lacunarity"), t[9], { + fgettext("This value multiplies every octave's scale by lacunarity^i where i is the place of the octave."), + fgettext("Example: If the lacunarity was 3, the 1st octave would be scaled by 1, the 2nd would be by 3, the 3rd would be by 9s, etc.")}) height = height + 1.1 @@ -107,11 +112,9 @@ Example: If the lacunarity was 0.5, the 1st octave would be scaled by 1, the 2nd for noise settings in the settings menu. ]] .. fgettext("defaults") .. ";" -- defaults .. tostring(flags["defaults"] == true) .. "]" -- to get false if nil - .. "tooltip[cb_defaults;" .. fgettext( -[[This flag overrides the eased flag based on the noise map type. - -2D noise will make eased on. -3D noise will make eased off.]]) .. "]" + .. "tooltip[cb_defaults;" .. fgettext("This flag overrides the eased flag based on the noise map type.") + .. "\n" .. fgettext("2D noise will make eased on.") + .. "\n" .. fgettext("3D noise will make eased off.") .. "]" .. "checkbox[5," .. height - 0.6 .. ";cb_eased;" --[[~ "eased" is a noise parameter flag. It is used to make the map smoother and @@ -119,11 +122,10 @@ Example: If the lacunarity was 0.5, the 1st octave would be scaled by 1, the 2nd the settings menu. ]] .. fgettext("eased") .. ";" -- eased .. tostring(flags["eased"] == true) .. "]" - .. "tooltip[cb_eased;" .. fgettext( -[[This flag maps noise gradient values onto a quintic S-curve before performing interpolation. -This results in smooth noise instead of gridlike noise. - -Making 3D noise eased is not recommended because it significantly increases the computation load.]]) .. "]" + .. "tooltip[cb_eased;" + .. fgettext("This flag maps noise gradient values onto a quintic S-curve before performing interpolation.") + .. "\n" .. fgettext("This results in smooth noise instead of gridlike noise.") + .. "\n" .. fgettext("Making 3D noise eased is not recommended because it significantly increases the load.") .. "]" .. "checkbox[5," .. height - 0.15 .. ";cb_absvalue;" --[[~ "absvalue" is a noise parameter flag. It is short for "absolute value". @@ -131,9 +133,9 @@ Making 3D noise eased is not recommended because it significantly increases the the settings menu. ]] .. fgettext("absvalue") .. ";" -- absvalue .. tostring(flags["absvalue"] == true) .. "]" - .. "tooltip[cb_absvalue;" .. fgettext( -[[This flag takes the absolute value of each octave while adding them together. -This results in "spiky" noise.]]) .. "]" + .. "tooltip[cb_absvalue;" + .. fgettext("This flag takes the absolute value of each octave while adding them together.") + .. "\n" .. fgettext("This results in spiky noise.") .. "]" height = height + 1 From 5b32dab7b5a489ac88e42758a5e8c739ab42bd03 Mon Sep 17 00:00:00 2001 From: birdlover32767 <162155761+birdlover32767@users.noreply.github.com> Date: Wed, 3 Sep 2025 11:27:28 +0300 Subject: [PATCH 4/6] Fix minor math mistake --- builtin/common/settings/dlg_change_mapgen_flags.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/common/settings/dlg_change_mapgen_flags.lua b/builtin/common/settings/dlg_change_mapgen_flags.lua index 17bfaf8b3a..5e5b4d1d9b 100644 --- a/builtin/common/settings/dlg_change_mapgen_flags.lua +++ b/builtin/common/settings/dlg_change_mapgen_flags.lua @@ -85,10 +85,10 @@ local function get_formspec(dialogdata) fgettext("An octave is a simple noise generator. Its scale and amplitude will be multiplied based on the Persistence and Lacunarity settings."), fgettext("Finally, all of the octaves will be added to generate this noise.")}) add_field(3.6, "te_persist", fgettext("Persistence"), t[8], { - fgettext("This value multiplies every octave's amplitude by persistence^i where i is the place of the octave."), + fgettext("This value multiplies every octave's amplitude by persistence^(i-1) where i is the place of the octave."), fgettext("Example: If the persistence was 0.5, the 1st octave would be amplified by 1, the 2nd would be by 0.5, the 3rd would be by 0.25, etc.")}) add_field(6.9, "te_lacun", fgettext("Lacunarity"), t[9], { - fgettext("This value multiplies every octave's scale by lacunarity^i where i is the place of the octave."), + fgettext("This value multiplies every octave's scale by lacunarity^(i-1) where i is the place of the octave."), fgettext("Example: If the lacunarity was 3, the 1st octave would be scaled by 1, the 2nd would be by 3, the 3rd would be by 9s, etc.")}) height = height + 1.1 From 99a6c124938d7c545d49e88e763c9978b82f39d3 Mon Sep 17 00:00:00 2001 From: birdlover32767 <162155761+birdlover32767@users.noreply.github.com> Date: Wed, 3 Sep 2025 11:29:01 +0300 Subject: [PATCH 5/6] Fix another minor mistake --- builtin/common/settings/dlg_change_mapgen_flags.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/common/settings/dlg_change_mapgen_flags.lua b/builtin/common/settings/dlg_change_mapgen_flags.lua index 5e5b4d1d9b..152f027a20 100644 --- a/builtin/common/settings/dlg_change_mapgen_flags.lua +++ b/builtin/common/settings/dlg_change_mapgen_flags.lua @@ -57,7 +57,7 @@ local function get_formspec(dialogdata) -- First row height = height + 0.3 add_field(0.3, "te_offset", fgettext("Offset"), t[1], {fgettext("This value offsets the final noise.")}) - add_field(3.6, "te_scale", fgettext("Scale"), t[2], {fgettext("This value multiplied with the noise before the offset is added.")}) + add_field(3.6, "te_scale", fgettext("Scale"), t[2], {fgettext("This value is multiplied with the noise before the offset is added.")}) add_field(6.9, "te_seed", fgettext("Seed"), t[6], { fgettext("This value acts as a random seed for the noise. The same seed results in the same noise.")}) height = height + 1.1 From ad6af8d7e1a341ebc882052df06eddfde7ac9938 Mon Sep 17 00:00:00 2001 From: birdlover32767 <162155761+birdlover32767@users.noreply.github.com> Date: Wed, 3 Sep 2025 11:46:40 +0300 Subject: [PATCH 6/6] Make luacheck happy --- .../settings/dlg_change_mapgen_flags.lua | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/builtin/common/settings/dlg_change_mapgen_flags.lua b/builtin/common/settings/dlg_change_mapgen_flags.lua index 152f027a20..54ca6b5c20 100644 --- a/builtin/common/settings/dlg_change_mapgen_flags.lua +++ b/builtin/common/settings/dlg_change_mapgen_flags.lua @@ -57,7 +57,8 @@ local function get_formspec(dialogdata) -- First row height = height + 0.3 add_field(0.3, "te_offset", fgettext("Offset"), t[1], {fgettext("This value offsets the final noise.")}) - add_field(3.6, "te_scale", fgettext("Scale"), t[2], {fgettext("This value is multiplied with the noise before the offset is added.")}) + add_field(3.6, "te_scale", fgettext("Scale"), t[2], { + fgettext("This value is multiplied with the noise before the offset is added.")}) add_field(6.9, "te_seed", fgettext("Seed"), t[6], { fgettext("This value acts as a random seed for the noise. The same seed results in the same noise.")}) height = height + 1.1 @@ -81,15 +82,18 @@ local function get_formspec(dialogdata) -- Third row add_field(0.3, "te_octaves", fgettext("Octaves"), t[7], { - fgettext("This value controls how many octaves the noise will have."), - fgettext("An octave is a simple noise generator. Its scale and amplitude will be multiplied based on the Persistence and Lacunarity settings."), + fgettext("This value controls how many octaves the noise will have."), "", + fgettext("An octave is a simple noise generator."), + fgettext("Its scale and amplitude will be multiplied based on the Persistence and Lacunarity settings."), fgettext("Finally, all of the octaves will be added to generate this noise.")}) add_field(3.6, "te_persist", fgettext("Persistence"), t[8], { - fgettext("This value multiplies every octave's amplitude by persistence^(i-1) where i is the place of the octave."), - fgettext("Example: If the persistence was 0.5, the 1st octave would be amplified by 1, the 2nd would be by 0.5, the 3rd would be by 0.25, etc.")}) + fgettext("This value multiplies every octave's amplitude by persistence^i where i is the place of the octave."), + fgettext("Example: If the persistence was 0.5, the 1st octave would be amplified by 1,"), + fgettext("the 2nd would be by 0.5, the 3rd would be by 0.25, etc.")}) add_field(6.9, "te_lacun", fgettext("Lacunarity"), t[9], { - fgettext("This value multiplies every octave's scale by lacunarity^(i-1) where i is the place of the octave."), - fgettext("Example: If the lacunarity was 3, the 1st octave would be scaled by 1, the 2nd would be by 3, the 3rd would be by 9s, etc.")}) + fgettext("This value multiplies every octave's scale by lacunarity^i where i is the place of the octave."), + fgettext("Example: If the lacunarity was 3, the 1st octave would be scaled by 1,"), + fgettext("the 2nd would be by 3, the 3rd would be by 9, etc.")}) height = height + 1.1 @@ -124,8 +128,8 @@ local function get_formspec(dialogdata) .. tostring(flags["eased"] == true) .. "]" .. "tooltip[cb_eased;" .. fgettext("This flag maps noise gradient values onto a quintic S-curve before performing interpolation.") - .. "\n" .. fgettext("This results in smooth noise instead of gridlike noise.") - .. "\n" .. fgettext("Making 3D noise eased is not recommended because it significantly increases the load.") .. "]" + .. "\n" .. fgettext("This results in smooth noise instead of gridlike noise.") .. "\n" + .. fgettext("Making 3D noise eased is not recommended because it significantly increases the load.") .. "]" .. "checkbox[5," .. height - 0.15 .. ";cb_absvalue;" --[[~ "absvalue" is a noise parameter flag. It is short for "absolute value".