mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-09-28 16:15:57 +00:00
55 lines
2.2 KiB
Lua
55 lines
2.2 KiB
Lua
|
local wea = worldeditadditions
|
||
|
|
||
|
-- ███████ ██████ ██ ██ ██ ██████ ████████ ██ ██ ███████ ████████
|
||
|
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||
|
-- ███████ ██ ██ ██ ██ ██████ ██ ██ ██ ███████ ██
|
||
|
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||
|
-- ███████ ██████ ██████ ███████ ██ ██ ███████ ██ ███████ ██
|
||
|
minetest.register_chatcommand("/sculptlist", {
|
||
|
params = "[preview]",
|
||
|
description = "Lists all the currently registered sculpting brushes and their associated metadata. If the keyword preview is specified as an argument, a preview of each brush is also printed.",
|
||
|
privs = { worldedit = true },
|
||
|
func = function(name, params_text)
|
||
|
if name == nil then return end
|
||
|
if not params_text then params_text = "" end
|
||
|
params_text = wea.trim(params_text)
|
||
|
|
||
|
local msg = {}
|
||
|
|
||
|
table.insert(msg, "Currently registered sculpting brushes:\n")
|
||
|
|
||
|
if params_text == "preview" then
|
||
|
for brush_name, brush_def in pairs(wea.sculpt.brushes) do
|
||
|
local preview = wea.sculpt.preview_brush(brush_name)
|
||
|
|
||
|
local brush_size = "dynamic"
|
||
|
if type(brush_size) ~= "function" then
|
||
|
brush_size = brush_def.size
|
||
|
end
|
||
|
|
||
|
table.insert(msg, brush_name.." ["..brush_size.."]:\n")
|
||
|
table.insert(msg, preview.."\n\n")
|
||
|
end
|
||
|
else
|
||
|
local display = { { "Name", "Native Size" } }
|
||
|
for brush_name, brush_def in pairs(wea.sculpt.brushes) do
|
||
|
local brush_size = "dynamic"
|
||
|
if type(brush_size) ~= "function" then
|
||
|
brush_size = brush_def.size
|
||
|
end
|
||
|
|
||
|
table.insert(display, {
|
||
|
brush_name,
|
||
|
brush_size
|
||
|
})
|
||
|
end
|
||
|
-- Sort by brush name
|
||
|
table.sort(display, function(a, b) return a[1] < b[1] end)
|
||
|
|
||
|
table.insert(msg, worldeditadditions.format.make_ascii_table(display))
|
||
|
end
|
||
|
|
||
|
worldedit.player_notify(name, table.concat(msg))
|
||
|
end
|
||
|
})
|