mirror of
https://github.com/HybridDog/we_undo.git
synced 2024-12-13 01:23:17 +01:00
Fix //y support with the new worldedit
This commit is contained in:
parent
634c07156d
commit
f6197c0886
38
init.lua
38
init.lua
@ -302,15 +302,8 @@ end
|
|||||||
|
|
||||||
----------------------- Functions common to other ones -------------------------
|
----------------------- Functions common to other ones -------------------------
|
||||||
|
|
||||||
-- Catch confirmation requests (/y or /n follows)
|
-- Remember the last command overridings for //y
|
||||||
local y_pending = {}
|
local y_pending = {}
|
||||||
local we_notify = worldedit.player_notify
|
|
||||||
function worldedit.player_notify(name, msg)
|
|
||||||
if msg:sub(1, 43) == "WARNING: this operation could affect up to " then
|
|
||||||
y_pending[name] = true
|
|
||||||
end
|
|
||||||
return we_notify(name, msg)
|
|
||||||
end
|
|
||||||
|
|
||||||
override_chatcommand("/n",
|
override_chatcommand("/n",
|
||||||
function()
|
function()
|
||||||
@ -321,35 +314,36 @@ override_chatcommand("/n",
|
|||||||
override_chatcommand("/y",
|
override_chatcommand("/y",
|
||||||
function(...)
|
function(...)
|
||||||
local t = y_pending[command_invoker]
|
local t = y_pending[command_invoker]
|
||||||
if type(t) == "table"
|
if t and t.before then
|
||||||
and t.before then
|
|
||||||
t.before(...)
|
t.before(...)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
function(...)
|
function(...)
|
||||||
local t = y_pending[command_invoker]
|
local t = y_pending[command_invoker]
|
||||||
if type(t) == "table"
|
if t and t.after then
|
||||||
and t.after then
|
|
||||||
t.after(...)
|
t.after(...)
|
||||||
end
|
end
|
||||||
y_pending[command_invoker] = nil
|
y_pending[command_invoker] = nil
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
local function override_cc_with_confirm(cname, func_before, actual_func_after)
|
local function override_cc_with_confirm(cname, func_before, func_after)
|
||||||
-- remember the functions for /y if needed
|
-- Remember the functions for //y if needed
|
||||||
local function func_after(...)
|
-- func_before and func_after are always executed before and after
|
||||||
if y_pending[command_invoker] then
|
-- the command cname.
|
||||||
y_pending[command_invoker] = {before = func_before,
|
-- func_before and func_after are executed a second time if the
|
||||||
after = func_after}
|
-- player then calls //y (unless the player calls //n before //y).
|
||||||
|
-- Therefore these two functions should only do temporary overridings of
|
||||||
|
-- relevant functions, e.g. worldedit.cube.
|
||||||
|
local function func_after_wrap(...)
|
||||||
|
y_pending[command_invoker] = {before = func_before, after = func_after}
|
||||||
|
return func_after(...)
|
||||||
end
|
end
|
||||||
return actual_func_after(...)
|
return override_chatcommand(cname, func_before, func_after_wrap)
|
||||||
end
|
|
||||||
return override_chatcommand(cname, func_before, func_after)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- override the worldedit vmanip finish function to catch the data table
|
-- Override the worldedit vmanip finish function to catch the data table
|
||||||
local we_data = false
|
local we_data = false
|
||||||
local we_manip_end = worldedit.manip_helpers.finish
|
local we_manip_end = worldedit.manip_helpers.finish
|
||||||
function worldedit.manip_helpers.finish(manip, data)
|
function worldedit.manip_helpers.finish(manip, data)
|
||||||
|
Loading…
Reference in New Issue
Block a user