//unmark: add optional all argument

This commit is contained in:
Starbeamrainbowlabs 2023-08-12 13:20:24 +01:00
parent 1abab143e7
commit 448cf0d674
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
2 changed files with 30 additions and 7 deletions

View File

@ -4,6 +4,10 @@ It's about time I started a changelog! This will serve from now on as the main c
Note to self: See the bottom of this file for the release template text.
## v1.15: The untitled update (unreleased)
- Added the optional argument `all` to [`//unmark`](https://worldeditadditions.mooncarrot.space/Reference/#unmark)
## v1.14.5: The multipoint update, hotfix 5 (1st August 2023)
- Fix a bug where creative players in survival couldn't punch out position markers
- Added `//listentities`, which lists all currently loaded `ObjectRef`s. This is intended for debugging mods - thanks to @Zughy in #103

View File

@ -6,26 +6,45 @@ if minetest.registered_chatcommands["/unmark"] then
worldedit_unmark = minetest.registered_chatcommands["/unmark"].func
end
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
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)
if params_text == "all" then
local removed = do_unmark_all()
worldedit.player_notify(name, "Hidden "..removed.." marker entities")
else
-- Hide the WorldEditAdditions marker
weac.pos.unmark(name)
end
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.",
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.",
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.",
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.",
privs = { worldedit = true },
func = do_unmark
})