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

43 lines
1.5 KiB
Lua
Raw Normal View History

2024-09-12 22:05:57 +00:00
-- local wea = worldeditadditions
local wea_c = worldeditadditions_core
local Vector3 = wea_c.Vector3
-- ███████ ██████ ██████ ██████ ██ ██
-- ██ ██ ██ ██ ██ ██ ██ ██
-- ███████ ██ ███ ██████ ██ ██ ██ █ ██
-- ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
-- ███████ ██████ ██ ██ ██████ ███ ███
2024-09-12 22:09:04 +00:00
worldeditadditions_core.register_command("sgrow", {
2024-09-17 19:31:02 +00:00
params = "<Unified Axis Keywords>",
2024-09-12 22:09:04 +00:00
description = "Grow selection region",
2024-09-12 22:05:57 +00:00
privs = { worldedit = true },
require_pos = 0,
parse = function(params_text)
local ret = wea_c.split(params_text)
2024-09-13 00:45:19 +00:00
if #ret < 1 then return false, "SGROW: No params found!"
2024-09-12 22:05:57 +00:00
else return true, ret end
end,
func = function(name, params_text)
local facing = wea_c.player_dir(name)
local min, max = wea_c.parse.directions(params_text, facing)
2024-09-15 16:15:22 +00:00
if not min then return false, max end
2024-09-12 22:05:57 +00:00
local pos1 = wea_c.pos.get(name, 1)
local pos2 = wea_c.pos.get(name, 2)
if not pos2 then wea_c.pos.set(name, 2, pos1)
else pos1, pos2 = Vector3.sort(pos1, pos2) end
2024-09-13 00:30:42 +00:00
pos1, pos2 = pos1:add(min), pos2:add(max)
2024-09-12 22:05:57 +00:00
wea_c.pos.set_all(name, {pos1, pos2})
return true, "Pos1 set to "..pos1..", Pos2 set to "..pos2
end,
})
-- Tests
-- //srel front 5 left 3 y 2