Minetest-WorldEditAdditions/worldeditadditions_commands/commands/selectors/sshift.lua

35 lines
1.3 KiB
Lua
Raw Normal View History

2022-09-18 21:20:04 +00:00
local wea_c = worldeditadditions_core
local Vector3 = worldeditadditions.Vector3
2021-07-30 21:02:46 +00:00
-- ███████ ███████ ██ ██ ██ ███████ ████████
-- ██ ██ ██ ██ ██ ██ ██
-- ███████ ███████ ███████ ██ █████ ██
-- ██ ██ ██ ██ ██ ██ ██
-- ███████ ███████ ██ ██ ██ ██ ██
2022-09-18 21:20:04 +00:00
worldeditadditions_core.register_command("sshift", {
2024-09-17 19:31:02 +00:00
params = "<Unified Axis Keywords>",
2021-07-30 21:02:46 +00:00
description = "Shift the WorldEdit region in 3 dimensions.",
privs = { worldedit = true },
require_pos = 2,
parse = function(params_text)
2024-09-15 16:15:22 +00:00
local ret = wea_c.split(params_text)
if #ret < 1 then return false, "SSHIFT: No params found!"
else return true, ret end
2021-07-30 21:02:46 +00:00
end,
func = function(name, params_text)
2024-09-15 16:15:22 +00:00
local facing = wea_c.player_dir(name)
local vec, err = wea_c.parse.directions(params_text, facing, true)
if not vec then return false, err end
2021-07-30 21:02:46 +00:00
2024-09-15 16:15:22 +00:00
local pos1 = vec:add(wea_c.pos.get(name, 1))
local pos2 = vec:add(wea_c.pos.get(name, 2))
2021-07-30 21:02:46 +00:00
2024-09-15 16:15:22 +00:00
wea_c.pos.set_all(name, {pos1, pos2})
return true, "Pos1 set to "..pos1..", Pos2 set to "..pos2
2021-07-30 21:02:46 +00:00
end,
})
-- Tests
-- //srel front 5 left 3 y 2