mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-21 23:13:00 +00:00
//subdivide: fix passing arguments to the command being executed
This commit is contained in:
parent
d2a1913e90
commit
ee3effd458
3 changed files with 13 additions and 1 deletions
|
@ -11,6 +11,7 @@ It's about time I started a changelog! This will serve from now on as the main c
|
|||
- `//subdivide`: Improve performance of initial chunk counting algorithm - it should get started on the job _much_ quicker now (especially on large regions)
|
||||
- `//subdivide`: Fix a bug where the entire defined region was emerged all at once instead of in chunks
|
||||
- `//subdivide`: Fix performance & memory usage issues
|
||||
- Fix passing arguments to the command being executed
|
||||
- If you encounter any other issues with it over large areas (particularly 2000x150x2000 and larger), please let me know
|
||||
- Bugfix: Fix obscure crash in calls to `human_size` ("unknown" will now be returned if passed junk)
|
||||
- `//many` can now be used with commands with no arguments.
|
||||
|
|
|
@ -79,6 +79,10 @@ worldedit.register_command("subdivide", {
|
|||
return false, "Error: Your privileges are unsufficient to run '"..cmd_name.."'."
|
||||
end
|
||||
|
||||
if cmd.require_pos ~= 2 then
|
||||
return false, "Error: The WorldEdit command '"..cmd_name.."' does not take 2 region markers, so can't be executed using //subdivide."
|
||||
end
|
||||
|
||||
-- local chunks_total = math.ceil((pos2.x - pos1.x) / (chunk_size.x - 1))
|
||||
-- * math.ceil((pos2.y - pos1.y) / (chunk_size.y - 1))
|
||||
-- * math.ceil((pos2.z - pos1.z) / (chunk_size.z - 1))
|
||||
|
@ -86,6 +90,12 @@ worldedit.register_command("subdivide", {
|
|||
local msg_prefix = "[ subdivide | "..wea.trim(table.concat({cmd_name, args}, " ")).." ] "
|
||||
local time_last_msg = wea.get_ms_time()
|
||||
|
||||
local cmd_args_parsed = {cmd.parse(args)}
|
||||
local success = table.remove(cmd_args_parsed, 1)
|
||||
if not success then
|
||||
return false, cmd_name..": "..(parsed[1] or "invalid usage")
|
||||
end
|
||||
|
||||
wea.subdivide(pos1, pos2, chunk_size, function(cpos1, cpos2, stats)
|
||||
-- Called on every subblock
|
||||
if stats.chunks_completed == 1 then
|
||||
|
@ -107,7 +117,7 @@ worldedit.register_command("subdivide", {
|
|||
worldedit.pos1[name] = cpos1
|
||||
worldedit.pos2[name] = cpos2
|
||||
worldedit.marker_update(name)
|
||||
cmd.func(name, args)
|
||||
cmd.func(name, unpack(cmd_args_parsed))
|
||||
if will_trigger_saferegion(name, cmd_name, args) then
|
||||
minetest.chatcommands["/y"].func(name)
|
||||
end
|
||||
|
|
|
@ -28,6 +28,7 @@ worldedit.register_command("scale", {
|
|||
privs = { worldedit = true },
|
||||
require_pos = 2,
|
||||
parse = function(params_text)
|
||||
print("[DEBUG//scale] got params_text '"..params_text.."'")
|
||||
if not params_text then params_text = "" end
|
||||
|
||||
local parts = worldeditadditions.split(params_text, "%s+", false)
|
||||
|
|
Loading…
Reference in a new issue