dissabled macros -- too buggy

This commit is contained in:
VorTechnix 2021-07-29 15:49:37 -07:00
parent 5757ef892d
commit b795f3b169
3 changed files with 39 additions and 12 deletions

View file

@ -11,7 +11,7 @@ local we_cm = worldeditadditions_commands.modpath .. "/commands/meta/"
dofile(we_cm.."airapply.lua")
dofile(we_cm.."ellipsoidapply.lua")
dofile(we_cm.."for.lua")
dofile(we_cm.."macro.lua")
-- dofile(we_cm.."macro.lua") -- Async bug
dofile(we_cm.."many.lua")
dofile(we_cm.."multi.lua")
dofile(we_cm.."subdivide.lua")

View file

@ -16,7 +16,7 @@ local function step(params)
-- Load current command string to use
local command, args = params.commands[params.i]:match("/([^%s]+)%s*(.*)$")
if not args then args = ""
else args = wea.trim(args) end
else args = args:match("^%s*(.*)%s*$") end
-- Get command and test privs
local cmd = minetest.chatcommands[command]
if not cmd then
@ -37,7 +37,7 @@ local function step(params)
if params.i <= #params.commands then
-- If we haven't run out of values call function again
minetest.after(0, step, params)
minetest.after(params.delay, step, params) -- Time is in seconds
else
worldedit.player_notify(params.player_name, "The macro \""..
params.file.."\" was completed in " ..
@ -46,20 +46,31 @@ local function step(params)
end
worldedit.register_command("macro", {
params = "<file>",
description = "Load commands from \"(world folder)/macros/<file>[.weamac | .wmac]\" with position 1 of the current WorldEdit region as the origin",
params = "<file> [<delay=0>]",
description = "Load commands from \"(world folder)/macros/<file>[.weamac | .wmac]\" with position 1 of the current WorldEdit region as the origin.",
privs = {worldedit=true},
require_pos = 0,
parse = function(params_text)
if params_text == "" then
return false
local parts = wea.split(params_text,"%s")
local file_name, delay -- = params_text:match("^(.-)%s*(%d*%.?%d*)$")
-- Check for params and delay
if not parts[1] then
return false, "Error: Insufficient arguments. Expected: \"<file> [<delay=0>]\""
elseif not parts[#parts]:match("[^%d%.]") then
delay = table.remove(parts,#parts)
file_name = table.concat(parts," ")
else
delay = 0
file_name = table.concat(parts," ")
end
if params_text:match("[!\"#%%&'%(%)%*%+,/:;<=>%?%[\\]%^`{|}]") then
-- Check file name
if file_name:match("[!\"#%%&'%(%)%*%+,/:;<=>%?%[\\]%^`{|}]") then
return false, "Disallowed file name: " .. params_text
end
return true, wea.trim(params_text)
return true, file_name, delay
end,
func = function(name, file_name)
func = function(name, file_name, delay)
if not worldedit.pos1[name] then
worldedit.pos1[name] = v3.add(wea.player_vector(name), v3.new(0.5,-0.5,0.5)):floor()
worldedit.mark_pos1(name)
@ -87,6 +98,7 @@ worldedit.register_command("macro", {
step({
player_name = name,
file = file_name:match("^[^%.]+"),
delay = delay,
commands = wea.split(value,"[\n\r]+")
})

View file

@ -1,9 +1,10 @@
local we_c = worldeditadditions_core
function we_c.register_command(name, def)
local success, def = we_c.check(def)
local def = table.copy(def)
local success, err = we_c.check_command(name, def)
if not success then
return false, def
return false, err
end
minetest.register_chatcommand("/" .. name, {
@ -16,3 +17,17 @@ function we_c.register_command(name, def)
})
worldedit.registered_commands[name] = def
end
function we_c.alias_command(alias, original)
if not worldedit.registered_commands[original] then
minetest.log("error", "worldedit_shortcommands: original " .. original .. " does not exist")
return
end
if minetest.chatcommands["/" .. alias] then
minetest.log("error", "worldedit_shortcommands: alias " .. alias .. " already exists")
return
end
minetest.register_chatcommand("/" .. alias, minetest.chatcommands["/" .. original])
worldedit.registered_commands[alias] = worldedit.registered_commands[original]
end