mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-10-31 21:33:02 +00:00
Make //unmark WEA-aware
Backwards compatibility with WE is maintained.
This commit is contained in:
parent
e916057133
commit
3bfc62be24
5 changed files with 57 additions and 2 deletions
|
@ -20,6 +20,7 @@ dofile(we_cmdpath.."spush.lua")
|
||||||
dofile(we_cmdpath.."srect.lua")
|
dofile(we_cmdpath.."srect.lua")
|
||||||
dofile(we_cmdpath.."sshift.lua")
|
dofile(we_cmdpath.."sshift.lua")
|
||||||
dofile(we_cmdpath.."sstack.lua")
|
dofile(we_cmdpath.."sstack.lua")
|
||||||
|
dofile(we_cmdpath.."unmark.lua")
|
||||||
|
|
||||||
-- Aliases
|
-- Aliases
|
||||||
worldedit.alias_command("sfac", "sfactor")
|
worldedit.alias_command("sfac", "sfactor")
|
||||||
|
|
32
worldeditadditions_commands/commands/selectors/unmark.lua
Normal file
32
worldeditadditions_commands/commands/selectors/unmark.lua
Normal file
|
@ -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
|
|
@ -250,6 +250,14 @@ local function push(player_name, pos)
|
||||||
return #positions[player_name]
|
return #positions[player_name]
|
||||||
end
|
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({
|
anchor = wea_c.EventEmitter.new({
|
||||||
get = get,
|
get = get,
|
||||||
|
@ -265,7 +273,8 @@ anchor = wea_c.EventEmitter.new({
|
||||||
set1 = set1,
|
set1 = set1,
|
||||||
set2 = set2,
|
set2 = set2,
|
||||||
set_all = set_all,
|
set_all = set_all,
|
||||||
compat_worldedit_get = compat_worldedit_get
|
unmark = unmark,
|
||||||
|
compat_worldedit_get = compat_worldedit_get,
|
||||||
})
|
})
|
||||||
anchor.debug = false
|
anchor.debug = false
|
||||||
|
|
||||||
|
|
|
@ -83,3 +83,15 @@ wea_c.pos:addEventListener("clear", function(event)
|
||||||
end
|
end
|
||||||
position_entities[event.player_name] = nil
|
position_entities[event.player_name] = nil
|
||||||
end)
|
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)
|
|
@ -70,3 +70,4 @@ weac.pos:addEventListener("set", handle_event)
|
||||||
weac.pos:addEventListener("pop", handle_event)
|
weac.pos:addEventListener("pop", handle_event)
|
||||||
weac.pos:addEventListener("push", handle_event)
|
weac.pos:addEventListener("push", handle_event)
|
||||||
weac.pos:addEventListener("clear", do_delete)
|
weac.pos:addEventListener("clear", do_delete)
|
||||||
|
weac.pos:addEventListener("unmark", do_delete)
|
||||||
|
|
Loading…
Reference in a new issue