2021-12-27 03:11:52 +00:00
local wea = worldeditadditions
2022-09-18 21:46:20 +00:00
local wea_c = worldeditadditions_core
2021-12-27 03:11:52 +00:00
-- ███████ ██████ ██ ██ ██ ██████ ████████ ██ ██ ███████ ████████
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ███████ ██ ██ ██ ██ ██████ ██ ██ ██ ███████ ██
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ███████ ██████ ██████ ███████ ██ ██ ███████ ██ ███████ ██
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
2022-09-18 21:46:20 +00:00
params_text = wea_c.trim ( params_text )
2021-12-27 03:11:52 +00:00
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
2021-12-27 19:36:57 +00:00
local success , preview = wea.sculpt . preview_brush ( brush_name )
2021-12-27 03:11:52 +00:00
local brush_size = " dynamic "
2021-12-27 19:36:57 +00:00
if type ( brush_def ) ~= " function " then
2021-12-31 01:43:53 +00:00
brush_size = brush_def.size . x .. " x " .. brush_def.size . y
2021-12-27 03:11:52 +00:00
end
2021-12-27 19:36:57 +00:00
print ( " //sculptlist: preview for " .. brush_name .. " : " )
print ( preview )
2021-12-27 03:11:52 +00:00
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 "
2021-12-27 19:36:57 +00:00
if type ( brush_def ) ~= " function " then
2021-12-27 03:11:52 +00:00
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 )
2022-09-18 21:46:20 +00:00
table.insert ( msg , wea_c.format . make_ascii_table ( display ) )
2021-12-27 03:11:52 +00:00
end
2024-10-16 23:27:33 +00:00
wea_c.notify . info ( name , table.concat ( msg ) )
2021-12-27 03:11:52 +00:00
end
} )