//sshift added

This commit is contained in:
VorTechnix 2021-07-30 14:02:46 -07:00
parent b795f3b169
commit bd84979393
3 changed files with 62 additions and 1 deletions

View File

@ -372,6 +372,7 @@ This command is best explained with examples:
The above functions just like `//replace` - nothing special going on here. It replaces all `dirt` nodes with `stone`.
Let's make it more interesting:
```weacmd
@ -715,7 +716,6 @@ Short for _select center_. Sets pos1 and pos2 to the centre point(s) of the curr
//scentre
```
## `//srel <axis1> <length1> [<axis2> <length2> [<axis3> <length3>]]`
Short for _select relative_. Sets the pos2 at set distances along 3 axes relative to pos1. If pos1 is not set it will default to the node directly under the player. The axis arguments accept `x, y, z` as well as `up, down, left, right, front, back`. Left, right, front and back are relative to player facing direction. Negative (`-`) can be applied to the axis, the length or both. Implementation thanks to @VorTechnix.
@ -726,6 +726,15 @@ Short for _select relative_. Sets the pos2 at set distances along 3 axes relativ
//srel -z 12 -y -2 x -2
```
## `//sshift <axis1> <length1> [<axis2> <length2> [<axis3> <length3>]]`
Short for _selection shift_. Shifts the WorldEdit region along 3 axes. The axis arguments accept `x, y, z` as well as `up, down, left, right, front, back`. Left, right, front and back are relative to player facing direction. Negative (`-`) can be applied to the axis, the length or both. Implementation thanks to @VorTechnix.
```weacmd
//sshift back 4
//sshift right -2 up 2
//sshift -left 2 z -7 -y -4
//sshift -z 12 -y -2 x -2
```
## `//smake <operation:odd|even|equal> <mode:grow|shrink|average> [<target=xz> [<base>]]`
Short for _selection make_. Modifies existing selection by moving pos2. Allows you to make the selection an odd or even length on one or more axes or set two or more axes equal to each other or the longest, shortest or average of them. Implementation thanks to @VorTechnix.

View File

@ -18,6 +18,7 @@ dofile(we_cm.."smake.lua")
dofile(we_cm.."spop.lua")
dofile(we_cm.."spush.lua")
dofile(we_cm.."srect.lua")
dofile(we_cm.."sshift.lua")
dofile(we_cm.."sstack.lua")
-- Aliases

View File

@ -0,0 +1,51 @@
-- ███████ ███████ ██ ██ ██ ███████ ████████
-- ██ ██ ██ ██ ██ ██ ██
-- ███████ ███████ ███████ ██ █████ ██
-- ██ ██ ██ ██ ██ ██ ██
-- ███████ ███████ ██ ██ ██ ██ ██
local wea = worldeditadditions
local v3 = worldeditadditions.Vector3
local function parse_with_name(name,args)
local vec, tmp = v3.new(0, 0, 0), {}
local find, _, i = {}, 0, 0
repeat
_, i, tmp.proc = args:find("([%l%s+-]+%d+)%s*", i)
if tmp.proc:match("[xyz]") then
tmp.ax = tmp.proc:match("[xyz]")
tmp.dir = tonumber(tmp.proc:match("[+-]?%d+")) * (tmp.proc:match("-%l+") and -1 or 1)
else
tmp.ax, _ = wea.dir_to_xyz(name, tmp.proc:match("%l+"))
if not tmp.ax then return false, _ end
tmp.dir = tonumber(tmp.proc:match("[+-]?%d+")) * (tmp.proc:match("-%l+") and -1 or 1) * _
end
vec[tmp.ax] = tmp.dir
until not args:find("([%l%s+-]+%d+)%s*", i)
return true, vec
end
worldedit.register_command("sshift", {
params = "<axis1> <distance1> [<axis2> <distance2> [<axis3> <distance3>]]",
description = "Shift the WorldEdit region in 3 dimensions.",
privs = { worldedit = true },
require_pos = 2,
parse = function(params_text)
if params_text:match("([%l%s+-]+%d+)") then return true, params_text
else return false, "No acceptable params found" end
end,
func = function(name, params_text)
local _, vec = parse_with_name(name,params_text)
if not _ then return false, vec end
local pos1 = vec:add(worldedit.pos1[name])
worldedit.pos1[name] = pos1
worldedit.mark_pos1(name)
local pos2 = vec:add(worldedit.pos2[name])
worldedit.pos2[name] = pos2
worldedit.mark_pos2(name)
return true, "Region shifted by " .. (vec.x + vec.y + vec.z) .. " nodes."
end,
})
-- Tests
-- //srel front 5 left 3 y 2