mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 15:33:00 +00:00
dissabled macros -- too buggy
This commit is contained in:
parent
5757ef892d
commit
b795f3b169
3 changed files with 39 additions and 12 deletions
|
@ -11,7 +11,7 @@ local we_cm = worldeditadditions_commands.modpath .. "/commands/meta/"
|
||||||
dofile(we_cm.."airapply.lua")
|
dofile(we_cm.."airapply.lua")
|
||||||
dofile(we_cm.."ellipsoidapply.lua")
|
dofile(we_cm.."ellipsoidapply.lua")
|
||||||
dofile(we_cm.."for.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.."many.lua")
|
||||||
dofile(we_cm.."multi.lua")
|
dofile(we_cm.."multi.lua")
|
||||||
dofile(we_cm.."subdivide.lua")
|
dofile(we_cm.."subdivide.lua")
|
||||||
|
|
|
@ -16,7 +16,7 @@ local function step(params)
|
||||||
-- Load current command string to use
|
-- Load current command string to use
|
||||||
local command, args = params.commands[params.i]:match("/([^%s]+)%s*(.*)$")
|
local command, args = params.commands[params.i]:match("/([^%s]+)%s*(.*)$")
|
||||||
if not args then args = ""
|
if not args then args = ""
|
||||||
else args = wea.trim(args) end
|
else args = args:match("^%s*(.*)%s*$") end
|
||||||
-- Get command and test privs
|
-- Get command and test privs
|
||||||
local cmd = minetest.chatcommands[command]
|
local cmd = minetest.chatcommands[command]
|
||||||
if not cmd then
|
if not cmd then
|
||||||
|
@ -37,7 +37,7 @@ local function step(params)
|
||||||
|
|
||||||
if params.i <= #params.commands then
|
if params.i <= #params.commands then
|
||||||
-- If we haven't run out of values call function again
|
-- 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
|
else
|
||||||
worldedit.player_notify(params.player_name, "The macro \""..
|
worldedit.player_notify(params.player_name, "The macro \""..
|
||||||
params.file.."\" was completed in " ..
|
params.file.."\" was completed in " ..
|
||||||
|
@ -46,20 +46,31 @@ local function step(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
worldedit.register_command("macro", {
|
worldedit.register_command("macro", {
|
||||||
params = "<file>",
|
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",
|
description = "Load commands from \"(world folder)/macros/<file>[.weamac | .wmac]\" with position 1 of the current WorldEdit region as the origin.",
|
||||||
privs = {worldedit=true},
|
privs = {worldedit=true},
|
||||||
require_pos = 0,
|
require_pos = 0,
|
||||||
parse = function(params_text)
|
parse = function(params_text)
|
||||||
if params_text == "" then
|
local parts = wea.split(params_text,"%s")
|
||||||
return false
|
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
|
end
|
||||||
if params_text:match("[!\"#%%&'%(%)%*%+,/:;<=>%?%[\\]%^`{|}]") then
|
-- Check file name
|
||||||
|
if file_name:match("[!\"#%%&'%(%)%*%+,/:;<=>%?%[\\]%^`{|}]") then
|
||||||
return false, "Disallowed file name: " .. params_text
|
return false, "Disallowed file name: " .. params_text
|
||||||
end
|
end
|
||||||
return true, wea.trim(params_text)
|
|
||||||
|
return true, file_name, delay
|
||||||
end,
|
end,
|
||||||
func = function(name, file_name)
|
func = function(name, file_name, delay)
|
||||||
if not worldedit.pos1[name] then
|
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.pos1[name] = v3.add(wea.player_vector(name), v3.new(0.5,-0.5,0.5)):floor()
|
||||||
worldedit.mark_pos1(name)
|
worldedit.mark_pos1(name)
|
||||||
|
@ -87,6 +98,7 @@ worldedit.register_command("macro", {
|
||||||
step({
|
step({
|
||||||
player_name = name,
|
player_name = name,
|
||||||
file = file_name:match("^[^%.]+"),
|
file = file_name:match("^[^%.]+"),
|
||||||
|
delay = delay,
|
||||||
commands = wea.split(value,"[\n\r]+")
|
commands = wea.split(value,"[\n\r]+")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
local we_c = worldeditadditions_core
|
local we_c = worldeditadditions_core
|
||||||
function we_c.register_command(name, def)
|
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
|
if not success then
|
||||||
return false, def
|
return false, err
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("/" .. name, {
|
minetest.register_chatcommand("/" .. name, {
|
||||||
|
@ -16,3 +17,17 @@ function we_c.register_command(name, def)
|
||||||
})
|
})
|
||||||
worldedit.registered_commands[name] = def
|
worldedit.registered_commands[name] = def
|
||||||
end
|
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
|
||||||
|
|
Loading…
Reference in a new issue