2023-07-09 18:44:31 +00:00
local weac = worldeditadditions_core
local worldedit_unmark
if minetest.registered_chatcommands [ " /unmark " ] then
worldedit_unmark = minetest.registered_chatcommands [ " /unmark " ] . func
end
2023-08-12 12:20:24 +00:00
local function do_unmark_all ( )
local items_removed = 0
for id , obj in pairs ( minetest.object_refs ) do
if obj.get_luaentity then
local luaentity = obj : get_luaentity ( )
if luaentity and ( luaentity.name == " worldeditadditions:marker_wall " or luaentity.name == " worldeditadditions:position " ) then
obj : remove ( )
items_removed = items_removed + 1
end
end
end
return items_removed
end
2023-07-09 18:44:31 +00:00
local function do_unmark ( name , params_text )
-- Hide the WorldEdit marker, if appropriate
if type ( worldedit_unmark ) == " function " then
worldedit_unmark ( name , params_text )
end
2023-08-12 12:20:24 +00:00
if params_text == " all " then
local removed = do_unmark_all ( )
2024-10-17 02:22:34 +00:00
weac.notify . info ( name , " Hidden " .. removed .. " marker entities " )
2023-08-12 12:20:24 +00:00
else
-- Hide the WorldEditAdditions marker
weac.pos . unmark ( name )
end
2023-07-09 18:44:31 +00:00
end
if minetest.registered_chatcommands [ " /unmark " ] then
minetest.override_chatcommand ( " /unmark " , {
2023-08-12 12:20:24 +00:00
params = " [all] " ,
description = " Hide the markers for the defined region (and any other positions), but do not remove the points themselves. If the optional argument keyword 'all' is supplied, then all loaded markers are hidden, regardless of player ownership. " ,
2023-07-09 18:44:31 +00:00
func = do_unmark
} )
else
minetest.register_chatcommand ( " /unmark " , {
2023-08-12 12:20:24 +00:00
params = " [all] " ,
description = " Hide the markers for the defined region (and any other positions), but do not remove the points themselves. If the optional argument keyword 'all' is supplied, then all loaded markers are hidden, regardless of player ownership. " ,
2023-07-09 18:44:31 +00:00
privs = { worldedit = true } ,
func = do_unmark
} )
end