diff --git a/CHANGELOG.md b/CHANGELOG.md index ff85ef2..0719670 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,9 @@ Note to self: See the bottom of this file for the release template text. - Add new universal chance parsing - Any `` can now either be a 1-in-N number (e.g. `4`, `10`), or a percentage chance (e.g. `50%`, `10%`). - Caveat: Percentages are converted to a 1-in-N chance, but additionally that number is rounded down in some places - - `//torus`, `//hollowtorus`: Add optional new axes and hollow (for `//torus`) argument + - `//torus`, `//hollowtorus`: Add optional new axes + - `//torus`: Add optional hollow keyword + - `//layers`: Fix crash duee to outdated debug code ## v1.11: The big data update (25th January 2021) diff --git a/Chat-Command-Reference.md b/Chat-Command-Reference.md index 3d3e862..ca17307 100644 --- a/Chat-Command-Reference.md +++ b/Chat-Command-Reference.md @@ -127,13 +127,14 @@ Creates a hollow ellipsoid at position 1 with the radius `(rx, ry, rz)`. Works t ## `//torus [ [h[ollow]]]` Creates a solid torus at position 1 with the specified major and minor radii. The major radius is the distance from the centre of the torus to the centre of the circle bit, and the minor radius is the radius of the circle bit. -The optional axes sets the axes upon which the torus will lay flat. Possible values: `xy` (the default), `xz`, `yz`. +The optional axes sets the axes upon which the torus will lay flat. Possible values: `xy` (the default), `xz`, `yz`. A single axis may also be specified (i.e. `x`, `y`, or `z`) - this will be interpreted as the axis that runs through the hole in the middle of the torus. ``` //torus 15 5 stone -//torus 5 3 meselamp x -//torus 10 6 sandstone xz hollow -//torus 10 6 wool:red y h +//torus 5 3 meselamp +//torus 10 6 sandstone xz +//torus 10 6 wool:red y +//torus 25 10 dirt xz hollow ``` ## `//hollowtorus []` diff --git a/worldeditadditions/lib/torus.lua b/worldeditadditions/lib/torus.lua index 289fe33..ab84e8f 100644 --- a/worldeditadditions/lib/torus.lua +++ b/worldeditadditions/lib/torus.lua @@ -1,5 +1,5 @@ ---- Overlap command. Places a specified node on top of --- @module worldeditadditions.overlay +--- Generates torus shapes. +-- @module worldeditadditions.torus --- Generates a torus shape at the given position with the given parameters. -- @param position Vector The position at which to generate the torus. @@ -57,8 +57,8 @@ function worldeditadditions.torus(position, major_radius, minor_radius, target_n -- (x^2+y^2+z^2-(a^2+b^2))^2-4 a b (b^2-z^2) -- Where: -- (x, y, z) is the point - -- a is the major radius (centre to centre of circle) - -- b is the minor radius (radius of circle) + -- a is the major radius (centre of the ring to the centre of the torus) + -- b is the minor radius (radius of the ring) local comp_a = (sq.x+sq.y+sq.z - (major_radius_sq+minor_radius_sq)) local test_value = comp_a*comp_a - 4*major_radius*minor_radius*(minor_radius_sq-sq.z) diff --git a/worldeditadditions/utils/parse/weighted_nodes.lua b/worldeditadditions/utils/parse/weighted_nodes.lua index cbabda3..b4dc0ba 100644 --- a/worldeditadditions/utils/parse/weighted_nodes.lua +++ b/worldeditadditions/utils/parse/weighted_nodes.lua @@ -59,7 +59,5 @@ function worldeditadditions.parse.weighted_nodes(parts, as_list, func_normalise) else result[last_node_name] = 1 end end - print(worldeditadditions.format.map(result, " ")) - return true, result end diff --git a/worldeditadditions_commands/commands/torus.lua b/worldeditadditions_commands/commands/torus.lua index ac68f41..b87125e 100644 --- a/worldeditadditions_commands/commands/torus.lua +++ b/worldeditadditions_commands/commands/torus.lua @@ -39,8 +39,10 @@ local function parse_params_torus(params_text) return false, "Error: 2 or less axes must be specified. For example, xy is valid, but xzy is not." end - local hollow = parts[5] - if hollow == "false" then hollow = false end + local hollow = false + if parts[5] == "hollow" or parts[5] == "h" then + hollow = true + end -- Sort the axis names (this is important to ensure we can identify the direction properly) if axes == "yx" then axes = "xy" end @@ -64,7 +66,13 @@ worldedit.register_command("torus", { end, func = function(name, target_node, major_radius, minor_radius, axes, hollow) local start_time = worldeditadditions.get_ms_time() - local replaced = worldeditadditions.torus(worldedit.pos1[name], major_radius, minor_radius, target_node, axes, hollow) + local replaced = worldeditadditions.torus( + worldedit.pos1[name], + major_radius, minor_radius, + target_node, + axes, + hollow + ) local time_taken = worldeditadditions.get_ms_time() - start_time minetest.log("action", name .. " used //torus at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", replacing " .. replaced .. " nodes in " .. time_taken .. "s") @@ -85,9 +93,15 @@ worldedit.register_command("hollowtorus", { nodes_needed = function(name, target_node, major_radius, minor_radius) return math.ceil(2 * math.pi*math.pi * major_radius * minor_radius*minor_radius) end, - func = function(name, target_node, major_radius, minor_radius) + func = function(name, target_node, major_radius, minor_radius, axes) local start_time = worldeditadditions.get_ms_time() - local replaced = worldeditadditions.torus(worldedit.pos1[name], major_radius, minor_radius, target_node, axes, true) + local replaced = worldeditadditions.torus( + worldedit.pos1[name], + major_radius, minor_radius, + target_node, + axes, + true -- hollow + ) local time_taken = worldeditadditions.get_ms_time() - start_time minetest.log("action", name .. " used //hollowtorus at " .. worldeditadditions.vector.tostring(worldedit.pos1[name]) .. ", replacing " .. replaced .. " nodes in " .. time_taken .. "s")