2022-09-18 23:20:04 +02:00
|
|
|
local wea_c = worldeditadditions_core
|
|
|
|
local Vector3 = wea_c.Vector3
|
|
|
|
|
2021-03-09 20:05:03 +01:00
|
|
|
-- ███████ ██████ ██████ ██
|
|
|
|
-- ██ ██ ██ ██ ██
|
|
|
|
-- ███████ ██ ██ ██ ██
|
|
|
|
-- ██ ██ ██ ██ ██
|
|
|
|
-- ███████ ██████ ██████ ███████
|
2022-05-19 23:10:09 +02:00
|
|
|
worldeditadditions_core.register_command("scol", {
|
2021-03-09 20:05:03 +01:00
|
|
|
params = "[<axis1>] <length>",
|
|
|
|
description = "Set WorldEdit region position 2 at a set distance along 1 axis.",
|
|
|
|
privs = {worldedit=true},
|
|
|
|
require_pos = 1,
|
|
|
|
parse = function(params_text)
|
2022-09-18 23:20:04 +02:00
|
|
|
local vec, tmp = Vector3.new(0, 0, 0), {}
|
|
|
|
local find = wea_c.split(params_text, "%s", false)
|
|
|
|
local ax1, sn1, len = (tostring(find[1]):match('[xyz]') or "g"):sub(1,1), wea_c.getsign(find[1]), find[table.maxn(find)]
|
2021-03-09 20:05:03 +01:00
|
|
|
|
2021-03-09 20:19:47 +01:00
|
|
|
tmp.len = tonumber(len)
|
2021-03-11 03:44:27 +01:00
|
|
|
-- If len == nil cancel the operation
|
2021-03-10 22:21:33 +01:00
|
|
|
if not tmp.len then return false, "No length specified." end
|
2021-03-09 20:19:47 +01:00
|
|
|
-- If ax1 is bad send "get" order
|
|
|
|
if ax1 == "g" then tmp.get = true
|
|
|
|
else vec[ax1] = sn1 * tmp.len end
|
2021-03-09 20:05:03 +01:00
|
|
|
|
2021-03-09 20:19:47 +01:00
|
|
|
return true, vec, tmp
|
2021-03-11 21:59:04 +01:00
|
|
|
-- tmp carries:
|
|
|
|
-- The length (len) arguement to the main function for use if "get" is invoked there
|
|
|
|
-- The bool value "get" to tell the main function if it needs to populate missing information in vec
|
2021-03-09 20:05:03 +01:00
|
|
|
end,
|
2021-03-09 20:19:47 +01:00
|
|
|
func = function(name, vec, tmp)
|
|
|
|
if tmp.get then
|
2022-09-18 23:20:04 +02:00
|
|
|
local ax, dir = wea_c.player_axis2d(name)
|
2021-03-09 20:19:47 +01:00
|
|
|
vec[ax] = tmp.len * dir
|
2021-03-09 20:05:03 +01:00
|
|
|
end
|
|
|
|
|
2022-09-18 23:20:04 +02:00
|
|
|
local pos2 = vec + Vector3.clone(worldedit.pos1[name])
|
|
|
|
worldedit.pos2[name] = pos2
|
2021-03-09 20:05:03 +01:00
|
|
|
worldedit.mark_pos2(name)
|
2022-09-18 23:20:04 +02:00
|
|
|
return true, "position 2 set to "..pos2
|
2021-03-09 20:05:03 +01:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Tests
|
|
|
|
-- /multi //fp set1 -63 19 -20 //scol 5
|
|
|
|
|
|
|
|
-- lua print(worldedit.player_axis(myname))
|
|
|
|
-- tonumber(('y1'):gsub('[xyz]',''):sub(1,2))
|