-- =================================================================== local chat_send = minetest.chat_send_player -- =================================================================== local param_destroymeta = { description = "Destroy nodes with meta completely" , params = "radius (optional)" , privs = {} , privs = { worldedit=true } , func = function (plname, params) local str local radius = tonumber (params) if radius == nil then radius = 3 end if radius < 1 then radius = 1 end if radius > 10 then radius = 10 end local player = minetest.env:get_player_by_name (plname) local pos = player:getpos() local msgcount = 0 for xd = -radius, radius, 1 do for yd = -radius, radius, 1 do for zd = -radius, radius, 1 do local bpos = { x=pos.x+xd, y=pos.y+yd, z=pos.z+zd } local node = minetest.get_node (bpos) if node ~= nil then local meta = minetest.get_meta (bpos) local mtab = meta:to_table() if mtab ~= nil then local is_empty = true for _, v in pairs (mtab) do local vt = type (v) if vt == "string" then if ocutil.str_nonempty (v) then is_empty = false end elseif vt == "table" then if ocutil.table_nonempty (v) then is_empty = false end elseif vt ~= nil then is_empty = false end end if not is_empty then meta:from_table (nil) minetest.set_node (bpos, { name = "air" }) local bs = ocutil.pos_to_str (bpos) if msgcount < 8 then chat_send (plname, "Destroyed node at " .. bs) msgcount = msgcount + 1 end end end end end end end if msgcount == 0 then chat_send (plname, "There are no nodes with non-empty meta in radius " .. radius) else str = " nodes" if msgcount == 1 then str = " node" end chat_send (plname, "Destroyed " .. msgcount .. str) end end } minetest.register_chatcommand ("/destroymeta" , param_destroymeta) minetest.register_chatcommand ("destroymeta" , param_destroymeta) -- =================================================================== -- End of file.