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

40 lines
1.3 KiB
Lua
Raw Normal View History

2022-09-18 21:20:04 +00:00
local wea = worldeditadditions
local weac = worldeditadditions_core
2022-09-18 21:20:04 +00:00
2021-03-01 22:23:36 +00:00
-- ███████ ██████ ██████ ██████
-- ██ ██ ██ ██ ██ ██ ██
-- ███████ ██████ ██ ██ ██████
-- ██ ██ ██ ██ ██
-- ███████ ██ ██████ ██
worldeditadditions_core.register_command("spop", {
2021-03-01 22:23:36 +00:00
params = "",
description = "Pops a region off your (per-user) selection stack.",
privs = { worldedit = true },
parse = function(params_text)
return true
end,
nodes_needed = function(name)
return 0
end,
func = function(name)
2022-09-18 21:20:04 +00:00
local success, pos1, pos2 = wea.spop(name)
2021-03-01 22:23:36 +00:00
if not success then return success, pos1 end
weac.pos.set1(name, pos1)
weac.pos.set2(name, pos2)
-- worldedit.pos1[name] = pos1
-- worldedit.pos2[name] = pos2
-- worldedit.marker_update(name)
2021-03-01 22:23:36 +00:00
2022-09-18 21:20:04 +00:00
local new_count = wea.scount(name)
2021-03-01 22:23:36 +00:00
local plural = "s are"
if new_count == 1 then plural = " is" end
2022-09-18 21:20:04 +00:00
local region_text = pos1.." - "..pos2
2021-03-01 22:23:36 +00:00
2021-08-07 16:50:28 +00:00
minetest.log("action", name .. " used //spopped at "..region_text..". Stack height is now " .. new_count.." regions")
return true, "Region "..region_text.." popped from selection stack; "..new_count.." region"..plural.." now in the stack"
2021-03-01 22:23:36 +00:00
end
})