Merge branch 'main' into VorTechnix

This commit is contained in:
VorTechnix 2022-05-15 13:09:57 -07:00
commit bcfe39cd21
19 changed files with 1416 additions and 1986 deletions

@ -32,7 +32,6 @@ function calculate_size(width, height, size_spec) {
// Main task list - we make sure it completes before exiting.
var queue = null;
var pMemoize = null;
async function make_queue() {
// 1: Setup task queue

3088
.docs/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -20,18 +20,18 @@
},
"homepage": "https://github.com/sbrl/Minetest-WorldEditAdditions#readme",
"devDependencies": {
"@11ty/eleventy": "^0.12.1",
"chroma-js": "^2.1.2",
"columnify": "^1.5.4",
"debug": "^4.3.2",
"@11ty/eleventy": "^1.0.1",
"chroma-js": "^2.4.2",
"columnify": "^1.6.0",
"debug": "^4.3.4",
"imagickal": "^5.0.1",
"markdown-it-prism": "^2.2.1",
"markdown-it-prism": "^2.2.4",
"p-memoize": "^6.0.1",
"p-queue": "^7.1.0",
"phin": "^3.6.0",
"p-queue": "^7.2.0",
"phin": "^3.6.1",
"pretty-ms": "^7.0.1"
},
"dependencies": {
"html-entities": "^2.3.2"
"html-entities": "^2.3.3"
}
}

@ -3,6 +3,12 @@ It's about time I started a changelog! This will serve from now on as the main c
Note to self: See the bottom of this file for the release template text.
## v1.14: The untitled update (unreleased)
- Add `//dome+`, which allows you to change the direction the dome is pointing in, and also create multiple domes at once
- Migrate from `depends.txt` to `mod.conf`
## v1.13: The transformational update (2nd January 2022)
- Add [`//sfactor`](https://worldeditadditions.mooncarrot.space/Reference/#sfactor) (_selection factor_) - Selection Tools by @VorTechnix are finished for now.
- Add [`//mface`](https://worldeditadditions.mooncarrot.space/Reference/#mface) (_measure facing_), [`//midpos`](https://worldeditadditions.mooncarrot.space/Reference/#midpos) (_measure middle position_), [`//msize`](https://worldeditadditions.mooncarrot.space/Reference/#msize) (_measure size_), [`//mtrig`](#mtrig) (_measure trigonometry_) - Measuring Tools implemented by @VorTechnix.

@ -172,6 +172,22 @@ Generates both square and circular spiral shapes with the given `<replace_node>`
```
### `//dome+ <radius> <replace_node> [<pointing_dir:x|y|z|-x|-y|-z|?|front|back|left|right|up|down> ...] [h[ollow]]`
Creates a dome shape (i.e. a hemisphere; half a sphere) with a specified radius of the defined node, optionally specifying the direction it should be pointing in (defaults to the positive y direction).
For example, `//dome+ 5 stone y` creates a dome shape pointing upwards, but `//dome+ 5 stone -y` creates a dome shape pointing downwards.
Multiple pointing direction axes can be chained together to create multiple domes on top of each other. Multiple conflicting directions will cancel each other out.
If `h` or `hollow` is specified at the end, then the resulting dome shape is made hollow.
```
//dome+ 5 stone y
//dome+ 10 diamond -x
//dome+ 25 cactus y z
//dome+ 9 dirt x y z
```
## Misc
<!--

@ -1,3 +1,4 @@
name = worldeditadditions
description = Extra tools and commands to extend WorldEdit. Currently has over 22 commands!
depends = worldedit

@ -1,6 +0,0 @@
worldedit
bonemeal?
cool_trees?
default?
moretrees?
ethereal?

@ -58,6 +58,8 @@ dofile(wea.modpath.."/lib/scale_down.lua")
dofile(wea.modpath.."/lib/scale.lua")
dofile(wea.modpath.."/lib/spiral_square.lua")
dofile(wea.modpath.."/lib/spiral_circle.lua")
dofile(wea.modpath.."/lib/dome.lua")
dofile(wea.modpath.."/lib/metaballs.lua")
dofile(wea.modpath.."/lib/conv/conv.lua")
dofile(wea.modpath.."/lib/erode/erode.lua")
dofile(wea.modpath.."/lib/noise/init.lua")

@ -0,0 +1,83 @@
local wea = worldeditadditions
local Vector3 = wea.Vector3
-- ██████ ██████ ███ ███ ███████
-- ██ ██ ██ ██ ████ ████ ██
-- ██ ██ ██ ██ ██ ████ ██ █████
-- ██ ██ ██ ██ ██ ██ ██ ██
-- ██████ ██████ ██ ██ ███████
--- Creates a dome shape with the given node, optionally specifying the
-- direction the point should point.
-- @param pos Vector3 The central point to start drawing the dome from.
-- @param radius number The radius of the dome to create.
-- @param replace_node string The fully qualified name of the node to use to make the dome with.
-- @param pointing_dir Vector3 Optional. The direction the dome should point. Defaults to (0, 1, 0). See also wea.parse.axis_name.
-- @param hollow boolean Whether to make the dome hollow or not. Defaults to false.
function worldeditadditions.dome(pos, radius, replace_node, pointing_dir, hollow)
pos = Vector3.clone(pos)
local pos1 = pos - radius
local pos2 = pos + radius
if not pointing_dir then pointing_dir = Vector3.new(0, 1, 0) end
if hollow == nil then hollow = false end
-- pos2 will always have the highest co-ordinates now
-- Fetch the nodes in the specified area
local manip, area = worldedit.manip_helpers.init(pos1, pos2)
local data = manip:get_data()
local node_id_replace = minetest.get_content_id(replace_node)
local radius_sq = radius * radius
local radius_inner_sq = (radius-1) * (radius-1)
local centrepoint = Vector3.mean(pos1, pos2)
local replaced = 0
for z = pos2.z, pos1.z, -1 do
for y = pos2.y, pos1.y, -1 do
for x = pos2.x, pos1.x, -1 do
local distance_sq = (Vector3.new(x, y, z) - centrepoint):length_squared()
local is_in_range = distance_sq < radius_sq
if hollow and distance_sq < radius_inner_sq then
is_in_range = false
end
if is_in_range then
-- It's inside the radius, but we're still not sure given this is a dome and not a sphere
local should_include = false
if x < centrepoint.x and pointing_dir.x < 0 then
should_include = true
end
if x > centrepoint.x and pointing_dir.x > 0 then
should_include = true
end
if y < centrepoint.y and pointing_dir.y < 0 then
should_include = true
end
if y > centrepoint.y and pointing_dir.y > 0 then
should_include = true
end
if z < centrepoint.z and pointing_dir.z < 0 then
should_include = true
end
if z > centrepoint.z and pointing_dir.z > 0 then
should_include = true
end
if should_include then
data[area:index(x, y, z)] = node_id_replace
replaced = replaced + 1
end
end
end
end
end
-- Save the modified nodes back to disk & return
worldedit.manip_helpers.finish(manip, data)
return true, replaced
end

@ -0,0 +1,63 @@
local wea = worldeditadditions
local Vector3 = wea.Vector3
-- ███ ███ ███████ ████████ █████ ██████ █████ ██ ██ ███████
-- ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ████ ██ █████ ██ ███████ ██████ ███████ ██ ██ ███████
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ███████ ██ ██ ██ ██████ ██ ██ ███████ ███████ ███████
--- Renders 2 or more metaballs with the given node and threshold value.
-- direction the point should point.
-- @param metaballs [{pos: Vector3, radius: number}] Aa list of metaballs to render. Each metaball should be a table with 2 properties: pos - the position of the centre of the metaball as a Vector3, and radius - the radius of the metaball.
-- @param replace_node string The fully qualified name of the node to use to make the dome with.
function worldeditadditions.metaballs(metaballs, replace_node, threshold)
local pos1, pos2
if not threshold then threshold = 1 end
for i,metaball in ipairs(metaballs) do
local pos1_c = metaball.pos - metaball.radius
local pos2_c = metaball.pos + metaball.radius
if i == 1 then
pos1 = pos1_c
pos2 = pos2_c
end
pos1 = Vector3.min(pos1, pos1_c)
pos2 = Vector3.max(pos2, pos2_c)
end
-- pos2 will always have the highest co-ordinates now
-- Fetch the nodes in the specified area
local manip, area = worldedit.manip_helpers.init(pos1, pos2)
local data = manip:get_data()
local node_id_replace = minetest.get_content_id(replace_node)
local replaced = 0
for z = pos2.z, pos1.z, -1 do
for y = pos2.y, pos1.y, -1 do
for x = pos2.x, pos1.x, -1 do
local pos_here = Vector3.new(x, y, z)
local metaball_sum = 0
for i,metaball in ipairs(metaballs) do
local distance_sq = (metaball.pos - pos_here):length_squared()
local radius_sq = metaball.radius * metaball.radius
local falloff = (1 / (distance_sq/radius_sq)) ^ 2
metaball_sum = metaball_sum + falloff
end
if metaball_sum <= threshold then
data[area:index(x, y, z)] = node_id_replace
replaced = replaced + 1
end
end
end
end
-- Save the modified nodes back to disk & return
worldedit.manip_helpers.finish(manip, data)
return true, replaced
end

@ -0,0 +1,4 @@
name = worldeditadditions
description = Extra tools and commands to extend WorldEdit for Minetest
depends = worldedit
optional_depends = bonemeal, cool_trees, default, moretrees, ethereal

@ -0,0 +1,96 @@
local wea = worldeditadditions
local Vector3 = wea.Vector3
local function parse_stage2(name, parts)
local result = Vector3.new()
for i,axis_name in ipairs(parts) do
local success, result_this = wea.parse.axis_name(axis_name, wea.player_dir(name))
if not success then return success, result_this end
result = result + result_this
end
result = result:clamp(Vector3.new(-1, -1, -1), Vector3.new(1, 1, 1))
if result.length == 0 then
return false, "Refusing to create a dome with no distinct pointing direction."
end
return true, result
end
-- ██████ ██████ ███ ███ ███████
-- ██ ██ ██ ██ ████ ████ ██
-- ██ ██ ██ ██ ██ ████ ██ █████
-- ██ ██ ██ ██ ██ ██ ██ ██
-- ██████ ██████ ██ ██ ███████
worldedit.register_command("dome+", { -- TODO: Make this an override
params = "<radius> <replace_node> [<pointing_dir:x|y|z|-x|-y|-z|?|front|back|left|right|up|down> ...] [h[ollow]]",
description = "Creates a dome shape with a specified radius of the defined node, optionally specifying the direction it should be pointing in (defaults to the positive y direction).",
privs = { worldedit = true },
require_pos = 1,
parse = function(params_text)
if not params_text then params_text = "" end
local parts = wea.split_shell(params_text)
if #parts < 2 then
return false, "Error: Not enough arguments (see /help /dome for usage information)."
end
local radius = tonumber(parts[1])
local replace_node = worldedit.normalize_nodename(parts[2])
local hollow = false
if not radius then
return false, "Error: Invalid radius '"..parts[1].."'. The radius must be a positive integer."
end
if radius < 1 then
return false, "Error: The minimum radius size is 1, but you entered"..tostring(radius).."."
end
if not replace_node then
return false, "Error: Invalid replace_node '"..parts[1].."'."
end
if #parts > 2 and (parts[#parts] == "h" or parts[#parts] == "hollow") then
hollow = true
table.remove(parts, #parts)
end
local axes = wea.table.shallowcopy(parts)
table.remove(axes, 1)
table.remove(axes, 1)
if #axes == 0 then
table.insert(axes, "+y")
end
return true, radius, replace_node, axes, hollow
end,
nodes_needed = function(name, radius)
return 4/3 * math.pi * radius * radius * radius
end,
func = function(name, radius, replace_node, axes, hollow)
local start_time = wea.get_ms_time()
local success_a, pointing_dir = parse_stage2(name, axes)
if not success_a then return success_a, pointing_dir end
local pos = Vector3.clone(worldedit.pos1[name])
local success_b, nodes_replaced = wea.dome(
pos,
radius,
replace_node,
pointing_dir,
hollow
)
if not success_b then return success_b, nodes_replaced end
local time_taken = wea.get_ms_time() - start_time
minetest.log("action", name.." used //dome+ at "..pos.." with a radius of "..tostring(radius)..", modifying "..nodes_replaced.." nodes in "..wea.format.human_time(time_taken))
return true, nodes_replaced.." nodes replaced "..wea.format.human_time(time_taken)
end
})

@ -1,6 +0,0 @@
worldeditadditions
worldedit_commands
worldedit_shortcommands
worldedit
worldeditdebug?
bonemeal?

@ -38,6 +38,7 @@ dofile(we_c.modpath.."/commands/walls.lua")
dofile(we_c.modpath.."/commands/spiral2.lua")
dofile(we_c.modpath.."/commands/copy.lua")
dofile(we_c.modpath.."/commands/move.lua")
dofile(we_c.modpath.."/commands/dome.lua")
dofile(we_c.modpath.."/commands/count.lua")
dofile(we_c.modpath.."/commands/sculpt.lua")

@ -0,0 +1,4 @@
name = worldeditadditions_commands
description = worldeditadditions: chat command interfaces
depends = worldeditadditions, worldedit_commands, worldedit_shortcommands, worldedit
optional_depends = worldeditdebug, bonemeal

@ -1 +0,0 @@
worldedit?

@ -0,0 +1,3 @@
name = worldeditadditions_core
description = worldeditadditions: core components
optional_depends = worldedit

@ -1,2 +0,0 @@
worldedit
worldeditadditions

@ -0,0 +1,3 @@
name = worldeditadditions_farwand
description = worldeditadditions: convenient tool items
depends = worldedit, worldeditadditions