Add build modes

This commit is contained in:
Wuzzy 2022-04-20 18:46:10 +02:00
parent fe36adacd9
commit 6e86ecace5
2 changed files with 68 additions and 34 deletions

View File

@ -185,14 +185,24 @@ All noise values are either high or low and are divided
by the **midpoint**: Values equal to or higher than the
midpoint are high, otherwise low.
In 2D mode, the mapgen will a flat XZ plane with nodes,
one node for every value. Both low and high values
are used.
In 2D mode, the mapgen will be a flat XZ plane with nodes.
In 3D mode, the mapgen will place nodes at every position
with a value of greater than or equal to the midpoint.
Only high values will create visible nodes, low values
will be air.
in the 3D world.
###### Build modes
The drop-down list to the bottom right stands for the
“build modes”. This sets for which noise values nodes
will be generated:
* Auto: In 2D mode, generate nodes for every value,
in 3D mode, only generate nodes for high values
* All: Generate nodes for every value
* High only: Only generate nodes for high values
* Low only: Only generate nodes for low values
###### Node visualization
Generated nodes will be color-coded, which stands for the value:
@ -225,20 +235,11 @@ Getter for the exact values.
If you have problems seeing color differences, activate
the grayscale color palette in the mod settings.
The following settings are only used when you want
to place nodes in a certain area:
###### Node types
* X, Y, Z: Coordinates of the bottom left front corner if you
want to generate an area manually with “Apply and create”
* Size: Side length of the square or cube of the area/volume
to generate, if you generate it with “Apply and create”.
**ATTENTION:** Dont make this value too large
(especially in 3D), otherwise map generation
will take forever and the game freezes.
Finally, there is a list of node types. This is just to
give different visualizations of the same thing and has
no other meaning:
Right to the color settings, there is a list of node types.
This is for different node styles for different
noise visualizations:
* Solid Nodes: Simple, solid, opaque cubes
* Grid Nodes: Solid see-through nodes (like glass)
@ -250,11 +251,22 @@ no other meaning:
Solid Nodes are recommend to use normally.
Grid or Minibox nodes can be useful in 3D mode if you want to
expose the inner structure of complex 3D noises. This can be quite trippy,
consider reducing the render distance if you get dizzy.
Also be warned this might drop your FPS sharply, especially
if your rendering distance is too large.
expose the inner structure of complex 3D noises. This can be quite
trippy and reduce your FPS sharply, so consider reducing the
render distance.
###### Position settings
The following settings are only used when you want
to place nodes in a certain area:
* X, Y, Z: Coordinates of the bottom left front corner if you
want to generate an area manually with “Apply and create”
* Size: Side length of the square or cube of the area/volume
to generate, if you generate it with “Apply and create”.
**ATTENTION:** Dont make this value too large
(especially in 3D), otherwise map generation
will take forever and the game freezes.
#### Footer (Apply / Apply and close / Enable mapgen / Disable mapgen)

View File

@ -144,6 +144,19 @@ current_options.mid_color = 0.0
-- Currently selected nodetype for the mapgen (see `nodetypes` table)
current_options.nodetype = 1
-- Currently selected build mode for the mapgen (see below)
-- These modes are available:
-- * Auto (1): same as ALL in 2D mode, same as HIGH_ONLY in 3D mode
-- * All (2): build nodes for all noise values
-- * High only (3): build nodes for high noise values only
-- * Low only (4): build nodes for low noise values only
local BUILDMODE_AUTO = 1
local BUILDMODE_ALL = 2
local BUILDMODE_HIGH_ONLY = 3
local BUILDMODE_LOW_ONLY = 4
current_options.buildmode = BUILDMODE_AUTO
-- dimensions of current Perlin noise (2 or 3)
current_options.dimensions = 2
-- If greater than 1, the Perlin noise values are "pixelized". Noise values at
@ -685,10 +698,15 @@ local update_map = function(pos, noise, noiseparams, options, stats_mode)
-- Set node and param2
if perlin_value >= zeropoint then
vdata[index] = content_test_node
vdata2[index] = node_param2
if options.buildmode == BUILDMODE_ALL or options.buildmode == BUILDMODE_HIGH_ONLY or options.buildmode == BUILDMODE_AUTO then
vdata[index] = content_test_node
vdata2[index] = node_param2
else
vdata[index] = minetest.CONTENT_AIR
vdata2[index] = 0
end
else
if options.show_low == true then
if options.buildmode == BUILDMODE_ALL or options.buildmode == BUILDMODE_LOW_ONLY or (options.buildmode == BUILDMODE_AUTO and options.dimensions == 2) then
vdata[index] = content_test_node_low
vdata2[index] = node_param2
else
@ -1135,6 +1153,7 @@ local show_noise_formspec = function(player, noiseparams, profile_id)
local lacunarity = tostring(np.lacunarity or "")
local size = tostring(current_options.size or "")
local buildmode = tostring(current_options.buildmode or 1)
local sidelen = tostring(current_options.sidelen or "")
local pos_x, pos_y, pos_z = "", "", ""
if current_options.pos then
@ -1191,10 +1210,10 @@ local show_noise_formspec = function(player, noiseparams, profile_id)
autogen_label = S("Enable mapgen")
create_btn = "button[3.5,0;3,1;create;"..F(S("Apply and create")).."]"
xyzsize = [[
field[0.25,1.95;2,0.75;pos_x;]]..F(S("X"))..[[;]]..pos_x..[[]
field[2.35,1.95;2,0.75;pos_y;]]..F(S("Y"))..[[;]]..pos_y..[[]
field[4.45,1.95;2,0.75;pos_z;]]..F(S("Z"))..[[;]]..pos_z..[[]
field[6.55,1.95;2,0.75;size;]]..F(S("Size"))..[[;]]..size..[[]
field[0.25,1.95;1.5,0.75;pos_x;]]..F(S("X"))..[[;]]..pos_x..[[]
field[2.15,1.95;1.5,0.75;pos_y;]]..F(S("Y"))..[[;]]..pos_y..[[]
field[4.05,1.95;1.5,0.75;pos_z;]]..F(S("Z"))..[[;]]..pos_z..[[]
field[5.95,1.95;1.5,0.75;size;]]..F(S("Size"))..[[;]]..size..[[]
field_close_on_enter[pos_x;false]
field_close_on_enter[pos_y;false]
field_close_on_enter[pos_z;false]
@ -1261,11 +1280,12 @@ local show_noise_formspec = function(player, noiseparams, profile_id)
box[0,0;9.5,0.4;]]..FORMSPEC_HEADER_COLOR..[[]
label[0.15,0.2;]]..F(S("Node generation"))..[[]
field[0.25,0.75;1.5,0.75;value_mid;]]..F(S("Midpoint"))..[[;]]..value_mid..[[]
field[2.25,0.75;1.5,0.75;value_min;]]..F(S("Low color at"))..[[;]]..value_min..[[]
field[4.25,0.75;1.5,0.75;value_max;]]..F(S("High color at"))..[[;]]..value_max..[[]
field[2.15,0.75;1.5,0.75;value_min;]]..F(S("Low color at"))..[[;]]..value_min..[[]
field[4.05,0.75;1.5,0.75;value_max;]]..F(S("High color at"))..[[;]]..value_max..[[]
button[6.25,0.75;0.75,0.75;autocolor;]]..F(S("Auto"))..[[]
dropdown[7.55,0.75;1.75,0.75;nodetype;]]..nodetypes_list_str..[[;]]..nodetype_index..[[;true]
dropdown[7.55,0.75;1.9,0.75;nodetype;]]..nodetypes_list_str..[[;]]..nodetype_index..[[;true]
]]..xyzsize..[[
dropdown[7.55,1.95;1.9,0.75;buildmode;]]..F(S("Auto"))..","..F(S("All"))..","..F(S("High only"))..","..F(S("Low only"))..[[;]]..buildmode..[[;true]
tooltip[value_mid;]]..F(S("Noise values equal to or higher than the midpoint are treated as “high”, otherwise as “low” values. Used for node colorization. In 3D mode, low values will become air."))..[[]
tooltip[value_min;]]..F(S("The lowest noise value to be represented by the node color gradient. Not used in 3D mode."))..[[]
tooltip[value_max;]]..F(S("The highest noise value to be represented by the node color gradient."))..[[]
@ -1400,6 +1420,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local value_mid = tonumber(fields.value_mid)
local value_max = tonumber(fields.value_max)
local nodetype = tonumber(fields.nodetype)
local buildmode = tonumber(fields.buildmode)
if (offset and scale and spread and octaves and persistence) then
local defaults = formspec_states[name].defaults
local eased = formspec_states[name].eased
@ -1463,7 +1484,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return
end
if not (dimensions and sidelen and value_min and value_mid and value_max and nodetype) then
if not (dimensions and sidelen and value_min and value_mid and value_max and nodetype and buildmode) then
return
end
-- Convert dropdown index to actual dimensions number
@ -1522,6 +1543,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
current_options.mid_color = value_mid
current_options.max_color = value_max
current_options.nodetype = nodetype
current_options.buildmode = buildmode
if fields.toggle_autogen then
current_options.autogen = not current_options.autogen
if current_options.autogen then