diff --git a/worldeditadditions_commands/commands/selectors/init.lua b/worldeditadditions_commands/commands/selectors/init.lua index 5a82a5d..6b81f1a 100644 --- a/worldeditadditions_commands/commands/selectors/init.lua +++ b/worldeditadditions_commands/commands/selectors/init.lua @@ -20,6 +20,7 @@ dofile(we_cmdpath.."spush.lua") dofile(we_cmdpath.."srect.lua") dofile(we_cmdpath.."sshift.lua") dofile(we_cmdpath.."sstack.lua") +dofile(we_cmdpath.."unmark.lua") -- Aliases worldedit.alias_command("sfac", "sfactor") diff --git a/worldeditadditions_commands/commands/selectors/unmark.lua b/worldeditadditions_commands/commands/selectors/unmark.lua new file mode 100644 index 0000000..dc8a557 --- /dev/null +++ b/worldeditadditions_commands/commands/selectors/unmark.lua @@ -0,0 +1,32 @@ +local weac = worldeditadditions_core + + +local worldedit_unmark +if minetest.registered_chatcommands["/unmark"] then + worldedit_unmark = minetest.registered_chatcommands["/unmark"].func +end + +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 + + -- Hide the WorldEditAdditions marker + weac.pos.unmark(name) +end + +if minetest.registered_chatcommands["/unmark"] then + minetest.override_chatcommand("/unmark", { + params = "", + description = "Hide the markers for the defined region (and any other positions), but do not remove the points themselves.", + func = do_unmark + }) +else + minetest.register_chatcommand("/unmark", { + params = "", + description = "Hide the markers for the defined region (and any other positions), but do not remove the points themselves.", + privs = { worldedit = true }, + func = do_unmark + }) +end \ No newline at end of file diff --git a/worldeditadditions_core/core/pos.lua b/worldeditadditions_core/core/pos.lua index ea0bdfe..5111e38 100644 --- a/worldeditadditions_core/core/pos.lua +++ b/worldeditadditions_core/core/pos.lua @@ -250,6 +250,14 @@ local function push(player_name, pos) return #positions[player_name] end +--- Hides the visual markers for the given player's positions and defined region, but does not clear the points. +-- @param player_name string The name of the player to operate on. +local function unmark(player_name) + anchor:emit("unmark", { + player_name = player_name + }) +end + anchor = wea_c.EventEmitter.new({ get = get, @@ -265,7 +273,8 @@ anchor = wea_c.EventEmitter.new({ set1 = set1, set2 = set2, set_all = set_all, - compat_worldedit_get = compat_worldedit_get + unmark = unmark, + compat_worldedit_get = compat_worldedit_get, }) anchor.debug = false diff --git a/worldeditadditions_core/core/pos_marker_manage.lua b/worldeditadditions_core/core/pos_marker_manage.lua index e9412d0..d9999f9 100644 --- a/worldeditadditions_core/core/pos_marker_manage.lua +++ b/worldeditadditions_core/core/pos_marker_manage.lua @@ -82,4 +82,16 @@ wea_c.pos:addEventListener("clear", function(event) worldedit.marker_update(event.player_name) end position_entities[event.player_name] = nil +end) + +wea_c.pos:addEventListener("unmark", function(event) + ensure_player(event.player_name) + + if #position_entities[event.player_name] > 0 then + for _, entity in pairs(position_entities[event.player_name]) do + wea_c.entities.pos_marker.delete(entity) + end + end + + -- Note that this function is NOT WorldEdit compatible, because it is only called through our override of WorldEdit's `//unmark`, and WorldEdit doesn't have an API function to call to unmark and everything is complicated. end) \ No newline at end of file diff --git a/worldeditadditions_core/core/pos_marker_wall_manage.lua b/worldeditadditions_core/core/pos_marker_wall_manage.lua index 7a4ac84..f30c5aa 100644 --- a/worldeditadditions_core/core/pos_marker_wall_manage.lua +++ b/worldeditadditions_core/core/pos_marker_wall_manage.lua @@ -69,4 +69,5 @@ end weac.pos:addEventListener("set", handle_event) weac.pos:addEventListener("pop", handle_event) weac.pos:addEventListener("push", handle_event) -weac.pos:addEventListener("clear", do_delete) \ No newline at end of file +weac.pos:addEventListener("clear", do_delete) +weac.pos:addEventListener("unmark", do_delete)