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

34 lines
1.3 KiB
Lua
Raw Normal View History

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)
local success, pos1, pos2 = worldeditadditions.spop(name)
if not success then return success, pos1 end
worldedit.pos1[name] = pos1
worldedit.pos2[name] = pos2
worldedit.marker_update(name)
local new_count = worldeditadditions.scount(name)
local plural = "s are"
if new_count == 1 then plural = " is" end
local region_text = worldeditadditions.vector.tostring(worldedit.pos1[name]).." - "..worldeditadditions.vector.tostring(worldedit.pos2[name])
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
})