2022-09-18 21:46:20 +00:00
local wea_c = worldeditadditions_core
2021-02-24 16:40:53 +00:00
-- ███████ █████ ██████ ██ ██ ███ ██ ██████ █████ ██ ██ █████ ███████ ███████ ███████
-- ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ███████ ███████ ██████ ██ ██ ██ ██ ██ ██ ███ ███████ ██ ██ ███████ ███████ █████ ███████
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ███████ ██ ██ ██ ███████ ██ ██ ████ ██████ ██ ██ ███████ ██ ██ ██ ███████ ███████ ███████
2020-09-13 19:32:55 +00:00
minetest.register_chatcommand ( " /saplingaliases " , {
params = " [aliases|all_saplings] " ,
description = " Lists all the currently registered sapling aliases (default). A single argument is taken as the mode of operation. Current modes: aliases (default; as described previously), all_saplings (lists all node names with the group \" sapling \" ) " ,
privs = { worldedit = true } ,
func = function ( name , params_text )
if name == nil then return end
if params_text == " " or not params_text then
params_text = " aliases "
end
2021-02-25 03:35:20 +00:00
2020-09-13 19:32:55 +00:00
local msg = { }
2021-02-25 03:35:20 +00:00
2020-09-13 19:32:55 +00:00
if params_text == " aliases " then
table.insert ( msg , " Currently registered aliases: \n " )
2022-09-18 21:46:20 +00:00
local aliases = wea_c.get_all_sapling_aliases ( )
2020-09-13 19:32:55 +00:00
local display = { }
for node_name , alias in pairs ( aliases ) do
table.insert ( display , { node_name , alias } )
end
2020-09-14 00:19:15 +00:00
table.sort ( display , function ( a , b ) return a [ 2 ] < b [ 2 ] end )
2022-09-18 21:46:20 +00:00
table.insert ( msg , wea_c.format . make_ascii_table ( display ) )
2020-09-13 19:32:55 +00:00
elseif params_text == " all_saplings " then
2022-09-18 21:46:20 +00:00
local results = wea_c.registered_nodes_by_group ( " sapling " )
2020-09-13 19:32:55 +00:00
table.insert ( msg , " Sapling-like nodes: \n " )
local str = table.concat ( results , " \n " )
table.insert ( msg , str )
else
table.insert ( msg , " Unknown mode ' " )
table.insert ( msg , params_text )
table.insert ( msg , " ' (valid modes: aliases, all_saplings). " )
end
worldedit.player_notify ( name , table.concat ( msg ) )
end
} )