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

47 lines
1.8 KiB
Lua
Raw Normal View History

2022-09-18 21:20:04 +00:00
local wea_c = worldeditadditions_core
2021-03-01 22:23:36 +00:00
-- ███████ ███████ ████████ █████ ██████ ██ ██
-- ██ ██ ██ ██ ██ ██ ██ ██
-- ███████ ███████ ██ ███████ ██ █████
-- ██ ██ ██ ██ ██ ██ ██ ██
-- ███████ ███████ ██ ██ ██ ██████ ██ ██
worldeditadditions_core.register_command("sstack", {
2021-03-01 22:23:36 +00:00
params = "",
description = "Displays the contents of 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 result = {"Stack contents for user ", name, ":\n"}
if not worldeditadditions.sstack[name] then
table.insert(result, "(empty)")
else
for i,item in ipairs(worldeditadditions.sstack[name]) do
2022-09-18 21:20:04 +00:00
-- TODO: Implement a volume command....
local volume = worldedit.volume(item[1], item[2])
2022-09-18 21:20:04 +00:00
local volume_text = wea_c.format.human_size(volume, 2)
if volume > 1000 then volume_text = "~"..volume_text end
2021-03-01 22:23:36 +00:00
table.insert(result, i)
table.insert(result, ": ")
table.insert(result, volume_text)
table.insert(result, " nodes - ")
2022-09-18 21:20:04 +00:00
table.insert(result, tostring(item[1])) -- Vector3 instance
2021-03-01 22:23:36 +00:00
table.insert(result, " - ")
2022-09-18 21:20:04 +00:00
table.insert(result, tostring(item[2])) -- Vector3 instance
2021-03-01 22:23:36 +00:00
table.insert(result, "\n")
end
table.insert(result, "========================\nTotal ")
table.insert(result, #worldeditadditions.sstack[name])
table.insert(result, " items")
end
return true, table.concat(result, "")
end
})