mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-26 00:53:00 +00:00
scentre and some sorting
This commit is contained in:
parent
0b55863d55
commit
20a879a7af
5 changed files with 67 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -39,3 +39,5 @@ luac.out
|
||||||
*.x86_64
|
*.x86_64
|
||||||
*.hex
|
*.hex
|
||||||
|
|
||||||
|
# Debug Tools (for now)
|
||||||
|
*debug/
|
||||||
|
|
|
@ -42,6 +42,17 @@ function worldeditadditions.vector.floor(v)
|
||||||
if v.z then v.z = math.floor(v.z) end
|
if v.z then v.z = math.floor(v.z) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Rounds the values in a vector up.
|
||||||
|
-- Warning: This MUTATES the given vector!
|
||||||
|
-- @param v Vector The vector to operate on
|
||||||
|
function worldeditadditions.vector.ceil(v)
|
||||||
|
if v.x then v.x = math.ceil(v.x) end
|
||||||
|
-- Some vectors are 2d, but on the x / z axes
|
||||||
|
if v.y then v.y = math.ceil(v.y) end
|
||||||
|
-- Some vectors are 2d
|
||||||
|
if v.z then v.z = math.ceil(v.z) end
|
||||||
|
end
|
||||||
|
|
||||||
--- Determines if the target point is contained within the defined worldedit region.
|
--- Determines if the target point is contained within the defined worldedit region.
|
||||||
-- @param pos1 Vector pos1 of the defined region.
|
-- @param pos1 Vector pos1 of the defined region.
|
||||||
-- @param pos2 Vector pos2 of the defined region.
|
-- @param pos2 Vector pos2 of the defined region.
|
||||||
|
@ -74,3 +85,11 @@ function worldeditadditions.vector.expand_region(pos1, pos2, target)
|
||||||
|
|
||||||
return pos1, pos2
|
return pos1, pos2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns the mean (average) of 2 positions to give you the centre.
|
||||||
|
-- @param pos1 Vector pos1 of the defined region.
|
||||||
|
-- @param pos2 Vector pos2 of the defined region.
|
||||||
|
-- @param target Vector Centre coordinates.
|
||||||
|
function worldeditadditions.vector.mean(pos1, pos2)
|
||||||
|
return vector.new((pos1.x + pos2.x)/2, (pos1.y + pos2.y)/2, (pos1.z + pos2.z)/2)
|
||||||
|
end
|
||||||
|
|
28
worldeditadditions_commands/commands/selectors/scentre.lua
Normal file
28
worldeditadditions_commands/commands/selectors/scentre.lua
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
-- ███████ ██████ ███████ ███ ██ ████████ ███████ ██████
|
||||||
|
-- ██ ██ ██ ████ ██ ██ ██ ██ ██
|
||||||
|
-- ███████ ██ █████ ██ ██ ██ ██ █████ ██████
|
||||||
|
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
-- ███████ ██████ ███████ ██ ████ ██ ███████ ██ ██
|
||||||
|
local wea = worldeditadditions
|
||||||
|
worldedit.register_command("scentre", {
|
||||||
|
params = "",
|
||||||
|
description = "Set WorldEdit region positions 1 and 2 to the centre of the current selection.",
|
||||||
|
privs = {worldedit=true},
|
||||||
|
require_pos = 2,
|
||||||
|
parse = function(params_text)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
func = function(name)
|
||||||
|
local vecs = {}
|
||||||
|
vecs.mean = wea.vector.mean(worldedit.pos1[name],worldedit.pos2[name])
|
||||||
|
vecs.p1, vecs.p2 = vector.new(vecs.mean), vector.new(vecs.mean)
|
||||||
|
wea.vector.floor(vecs.p1)
|
||||||
|
wea.vector.ceil(vecs.p2)
|
||||||
|
worldedit.pos1[name], worldedit.pos2[name] = vecs.p1, vecs.p2
|
||||||
|
worldedit.mark_pos1(name)
|
||||||
|
worldedit.mark_pos2(name)
|
||||||
|
return true, "position 1 set to " .. minetest.pos_to_string(vecs.p1) .. ", position 2 set to " .. minetest.pos_to_string(vecs.p2)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- lua print(vecs.mean.x..", "..vecs.mean.y..", "..vecs.mean.z)
|
|
@ -2,4 +2,5 @@ worldeditadditions
|
||||||
worldedit_commands
|
worldedit_commands
|
||||||
worldedit_shortcommands
|
worldedit_shortcommands
|
||||||
worldedit
|
worldedit
|
||||||
|
worldeditadditions_debug?
|
||||||
bonemeal?
|
bonemeal?
|
||||||
|
|
|
@ -19,20 +19,20 @@ dofile(we_c.modpath.."/player_notify_suppress.lua")
|
||||||
-- we_c.safe_region, we_c.check_region, we_c.reset_pending
|
-- we_c.safe_region, we_c.check_region, we_c.reset_pending
|
||||||
-- = dofile(we_c.modpath.."/safe.lua")
|
-- = dofile(we_c.modpath.."/safe.lua")
|
||||||
|
|
||||||
dofile(we_c.modpath.."/commands/floodfill.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/overlay.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/layers.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/fillcaves.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/ellipsoid.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/torus.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/line.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/walls.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/maze.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/replacemix.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/convolve.lua")
|
dofile(we_c.modpath.."/commands/convolve.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/ellipsoid.lua")
|
||||||
dofile(we_c.modpath.."/commands/erode.lua")
|
dofile(we_c.modpath.."/commands/erode.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/fillcaves.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/floodfill.lua")
|
||||||
dofile(we_c.modpath.."/commands/hollow.lua")
|
dofile(we_c.modpath.."/commands/hollow.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/layers.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/line.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/maze.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/overlay.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/replacemix.lua")
|
||||||
dofile(we_c.modpath.."/commands/scale.lua")
|
dofile(we_c.modpath.."/commands/scale.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/torus.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/walls.lua")
|
||||||
|
|
||||||
dofile(we_c.modpath.."/commands/count.lua")
|
dofile(we_c.modpath.."/commands/count.lua")
|
||||||
|
|
||||||
|
@ -41,13 +41,15 @@ dofile(we_c.modpath.."/commands/meta/many.lua")
|
||||||
dofile(we_c.modpath.."/commands/meta/subdivide.lua")
|
dofile(we_c.modpath.."/commands/meta/subdivide.lua")
|
||||||
dofile(we_c.modpath.."/commands/meta/ellipsoidapply.lua")
|
dofile(we_c.modpath.."/commands/meta/ellipsoidapply.lua")
|
||||||
|
|
||||||
|
-- dofile(we_c.modpath.."/commands/selectors/srel.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/selectors/scentre.lua")
|
||||||
dofile(we_c.modpath.."/commands/selectors/scloud.lua")
|
dofile(we_c.modpath.."/commands/selectors/scloud.lua")
|
||||||
dofile(we_c.modpath.."/commands/selectors/scol.lua")
|
dofile(we_c.modpath.."/commands/selectors/scol.lua")
|
||||||
dofile(we_c.modpath.."/commands/selectors/srect.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/selectors/scube.lua")
|
dofile(we_c.modpath.."/commands/selectors/scube.lua")
|
||||||
dofile(we_c.modpath.."/commands/selectors/sstack.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/selectors/spush.lua")
|
|
||||||
dofile(we_c.modpath.."/commands/selectors/spop.lua")
|
dofile(we_c.modpath.."/commands/selectors/spop.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/selectors/spush.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/selectors/srect.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/selectors/sstack.lua")
|
||||||
|
|
||||||
dofile(we_c.modpath.."/commands/extra/saplingaliases.lua")
|
dofile(we_c.modpath.."/commands/extra/saplingaliases.lua")
|
||||||
dofile(we_c.modpath.."/commands/extra/basename.lua")
|
dofile(we_c.modpath.."/commands/extra/basename.lua")
|
||||||
|
@ -68,3 +70,5 @@ worldedit.alias_command("naturalise", "layers")
|
||||||
worldedit.alias_command("naturalize", "layers")
|
worldedit.alias_command("naturalize", "layers")
|
||||||
|
|
||||||
worldedit.alias_command("flora", "bonemeal")
|
worldedit.alias_command("flora", "bonemeal")
|
||||||
|
|
||||||
|
worldedit.alias_command("mcount", "count")
|
||||||
|
|
Loading…
Reference in a new issue