Rename the randomized //set to //mix, style update, document changes.

This commit is contained in:
Uberi 2014-07-18 15:51:09 -04:00
parent d8aa7e72a7
commit 4b178bf709
2 changed files with 81 additions and 79 deletions

View File

@ -98,14 +98,23 @@ Display the volume of the current WorldEdit region.
//volume //volume
### `//set <node1> ...` ### `//set <node>`
Set the current WorldEdit region to a random mix of `<node1>`, `...`. Set the current WorldEdit region to `<node>`.
//set air //set air
//set cactus stone glass //set cactus
//set Bronze //set Blue Lightstone
//set mesecons:wire_00000000_off //set dirt with grass
### `//mix <node1> ...`
Fill the current WorldEdit region with a random mix of `<node1>`, `...`.
//mix air
//mix cactus stone glass sandstone
//mix Bronze
//mix default:cobble air
### `//replace <search node> <replace node>` ### `//replace <search node> <replace node>`

View File

@ -15,7 +15,7 @@ end
dofile(minetest.get_modpath("worldedit_commands") .. "/mark.lua") dofile(minetest.get_modpath("worldedit_commands") .. "/mark.lua")
dofile(minetest.get_modpath("worldedit_commands") .. "/safe.lua") dofile(minetest.get_modpath("worldedit_commands") .. "/safe.lua")
local get_position = function(name) local get_position = function(name) --position 1 retrieval function for when not using `safe_region`
local pos1 = worldedit.pos1[name] local pos1 = worldedit.pos1[name]
if pos1 == nil then if pos1 == nil then
worldedit.player_notify(name, "no position 1 selected") worldedit.player_notify(name, "no position 1 selected")
@ -279,12 +279,28 @@ minetest.register_chatcommand("/volume", {
}) })
minetest.register_chatcommand("/set", { minetest.register_chatcommand("/set", {
params = "<node>",
description = "Set the current WorldEdit region to <node>",
privs = {worldedit=true},
func = safe_region(function(name, param)
local node = get_node(name, param)
if not node then
worldedit.player_notify(name, "Could not identify node \"" .. param .. "\"")
return
end
local count = worldedit.set(worldedit.pos1[name], worldedit.pos2[name], node)
worldedit.player_notify(name, count .. " nodes set")
end, check_region),
})
minetest.register_chatcommand("/mix", {
params = "<node1> ...", params = "<node1> ...",
description = "Set the current WorldEdit region to a random mix of <node1>, ...", description = "Fill the current WorldEdit region with a random mix of <node1>, ...",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local nodes = {} local nodes = {}
for nodename in param:gmatch("[^%s]+") do for nodename in param:gmatch("[^,]+") do
local node = get_node(name, nodename) local node = get_node(name, nodename)
if not node then if not node then
worldedit.player_notify(name, "Could not identify node \"" .. name .. "\"") worldedit.player_notify(name, "Could not identify node \"" .. name .. "\"")
@ -323,11 +339,10 @@ minetest.register_chatcommand("/replace", {
description = "Replace all instances of <search node> with <replace node> in the current WorldEdit region", description = "Replace all instances of <search node> with <replace node> in the current WorldEdit region",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+(.+)$") local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+(.+)$")
local newsearchnode = worldedit.normalize_nodename(searchnode) local newsearchnode = worldedit.normalize_nodename(searchnode)
local newreplacenode = worldedit.normalize_nodename(replacenode) local newreplacenode = worldedit.normalize_nodename(replacenode)
local count = worldedit.replace(pos1, pos2, newsearchnode, newreplacenode) local count = worldedit.replace(worldedit.pos1[name], worldedit.pos2[name], newsearchnode, newreplacenode)
worldedit.player_notify(name, count .. " nodes replaced") worldedit.player_notify(name, count .. " nodes replaced")
end, check_replace), end, check_replace),
}) })
@ -337,11 +352,10 @@ minetest.register_chatcommand("/replaceinverse", {
description = "Replace all nodes other than <search node> with <replace node> in the current WorldEdit region", description = "Replace all nodes other than <search node> with <replace node> in the current WorldEdit region",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+(.+)$") local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+(.+)$")
local newsearchnode = worldedit.normalize_nodename(searchnode) local newsearchnode = worldedit.normalize_nodename(searchnode)
local newreplacenode = worldedit.normalize_nodename(replacenode) local newreplacenode = worldedit.normalize_nodename(replacenode)
local count = worldedit.replaceinverse(pos1, pos2, searchnode, replacenode) local count = worldedit.replaceinverse(worldedit.pos1[name], worldedit.pos2[name], searchnode, replacenode)
worldedit.player_notify(name, count .. " nodes replaced") worldedit.player_notify(name, count .. " nodes replaced")
end, check_replace), end, check_replace),
}) })
@ -366,10 +380,9 @@ minetest.register_chatcommand("/hollowsphere", {
description = "Add hollow sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>", description = "Add hollow sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos = worldedit.pos1[name]
local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$") local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$")
local node = get_node(name, nodename) local node = get_node(name, nodename)
local count = worldedit.hollow_sphere(pos, tonumber(radius), node) local count = worldedit.hollow_sphere(worldedit.pos1[name], tonumber(radius), node)
worldedit.player_notify(name, count .. " nodes added") worldedit.player_notify(name, count .. " nodes added")
end, check_sphere), end, check_sphere),
}) })
@ -379,10 +392,9 @@ minetest.register_chatcommand("/sphere", {
description = "Add sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>", description = "Add sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos = worldedit.pos1[name]
local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$") local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$")
local node = get_node(name, nodename) local node = get_node(name, nodename)
local count = worldedit.sphere(pos, tonumber(radius), node) local count = worldedit.sphere(worldedit.pos1[name], tonumber(radius), node)
worldedit.player_notify(name, count .. " nodes added") worldedit.player_notify(name, count .. " nodes added")
end, check_sphere), end, check_sphere),
}) })
@ -407,10 +419,9 @@ minetest.register_chatcommand("/hollowdome", {
description = "Add hollow dome centered at WorldEdit position 1 with radius <radius>, composed of <node>", description = "Add hollow dome centered at WorldEdit position 1 with radius <radius>, composed of <node>",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos = worldedit.pos1[name]
local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$") local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$")
local node = get_node(name, nodename) local node = get_node(name, nodename)
local count = worldedit.hollow_dome(pos, tonumber(radius), node) local count = worldedit.hollow_dome(worldedit.pos1[name], tonumber(radius), node)
worldedit.player_notify(name, count .. " nodes added") worldedit.player_notify(name, count .. " nodes added")
end, check_dome), end, check_dome),
}) })
@ -420,10 +431,9 @@ minetest.register_chatcommand("/dome", {
description = "Add dome centered at WorldEdit position 1 with radius <radius>, composed of <node>", description = "Add dome centered at WorldEdit position 1 with radius <radius>, composed of <node>",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos = worldedit.pos1[name]
local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$") local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$")
local node = get_node(name, nodename) local node = get_node(name, nodename)
local count = worldedit.dome(pos, tonumber(radius), node) local count = worldedit.dome(worldedit.pos1[name], tonumber(radius), node)
worldedit.player_notify(name, count .. " nodes added") worldedit.player_notify(name, count .. " nodes added")
end, check_dome), end, check_dome),
}) })
@ -448,7 +458,6 @@ minetest.register_chatcommand("/hollowcylinder", {
description = "Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>", description = "Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos = worldedit.pos1[name]
local found, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+(.+)$") local found, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+(.+)$")
length = tonumber(length) length = tonumber(length)
if axis == "?" then if axis == "?" then
@ -456,7 +465,7 @@ minetest.register_chatcommand("/hollowcylinder", {
length = length * sign length = length * sign
end end
local node = get_node(name, nodename) local node = get_node(name, nodename)
local count = worldedit.hollow_cylinder(pos, axis, length, tonumber(radius), node) local count = worldedit.hollow_cylinder(worldedit.pos1[name], axis, length, tonumber(radius), node)
worldedit.player_notify(name, count .. " nodes added") worldedit.player_notify(name, count .. " nodes added")
end, check_cylinder), end, check_cylinder),
}) })
@ -466,7 +475,6 @@ minetest.register_chatcommand("/cylinder", {
description = "Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>", description = "Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos = worldedit.pos1[name]
local found, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+(.+)$") local found, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+(.+)$")
length = tonumber(length) length = tonumber(length)
if axis == "?" then if axis == "?" then
@ -474,7 +482,7 @@ minetest.register_chatcommand("/cylinder", {
length = length * sign length = length * sign
end end
local node = get_node(name, nodename) local node = get_node(name, nodename)
local count = worldedit.cylinder(pos, axis, length, tonumber(radius), node) local count = worldedit.cylinder(worldedit.pos1[name], axis, length, tonumber(radius), node)
worldedit.player_notify(name, count .. " nodes added") worldedit.player_notify(name, count .. " nodes added")
end, check_cylinder), end, check_cylinder),
}) })
@ -484,7 +492,6 @@ minetest.register_chatcommand("/pyramid", {
description = "Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height <height>, composed of <node>", description = "Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height <height>, composed of <node>",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos = get_position(name)
local found, _, axis, height, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(.+)$") local found, _, axis, height, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(.+)$")
height = tonumber(height) height = tonumber(height)
if axis == "?" then if axis == "?" then
@ -492,7 +499,7 @@ minetest.register_chatcommand("/pyramid", {
height = height * sign height = height * sign
end end
local node = get_node(name, nodename) local node = get_node(name, nodename)
local count = worldedit.pyramid(pos, axis, height, node) local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node)
worldedit.player_notify(name, count .. " nodes added") worldedit.player_notify(name, count .. " nodes added")
end, end,
function(name, param) function(name, param)
@ -517,10 +524,9 @@ minetest.register_chatcommand("/spiral", {
description = "Add spiral centered at WorldEdit position 1 with side length <length>, height <height>, space between walls <space>, composed of <node>", description = "Add spiral centered at WorldEdit position 1 with side length <length>, height <height>, space between walls <space>, composed of <node>",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos = worldedit.pos1[name]
local found, _, length, height, space, nodename = param:find("^(%d+)%s+(%d+)%s+(%d+)%s+(.+)$") local found, _, length, height, space, nodename = param:find("^(%d+)%s+(%d+)%s+(%d+)%s+(.+)$")
local node = get_node(name, nodename) local node = get_node(name, nodename)
local count = worldedit.spiral(pos, tonumber(length), tonumber(height), tonumber(space), node) local count = worldedit.spiral(worldedit.pos1[name], tonumber(length), tonumber(height), tonumber(space), node)
worldedit.player_notify(name, count .. " nodes added") worldedit.player_notify(name, count .. " nodes added")
end, end,
function(name, param) function(name, param)
@ -544,7 +550,6 @@ minetest.register_chatcommand("/copy", {
description = "Copy the current WorldEdit region along the x/y/z/? axis by <amount> nodes", description = "Copy the current WorldEdit region along the x/y/z/? axis by <amount> nodes",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local found, _, axis, amount = param:find("^([xyz%?])%s+([+-]?%d+)$") local found, _, axis, amount = param:find("^([xyz%?])%s+([+-]?%d+)$")
if found == nil then if found == nil then
worldedit.player_notify(name, "invalid usage: " .. param) worldedit.player_notify(name, "invalid usage: " .. param)
@ -556,7 +561,7 @@ minetest.register_chatcommand("/copy", {
amount = amount * sign amount = amount * sign
end end
local count = worldedit.copy(pos1, pos2, axis, amount) local count = worldedit.copy(worldedit.pos1[name], worldedit.pos2[name], axis, amount)
worldedit.player_notify(name, count .. " nodes copied") worldedit.player_notify(name, count .. " nodes copied")
end, end,
function(name, param) function(name, param)
@ -597,14 +602,13 @@ minetest.register_chatcommand("/stack", {
description = "Stack the current WorldEdit region along the x/y/z/? axis <count> times", description = "Stack the current WorldEdit region along the x/y/z/? axis <count> times",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local found, _, axis, repetitions = param:find("^([xyz%?])%s+([+-]?%d+)$") local found, _, axis, repetitions = param:find("^([xyz%?])%s+([+-]?%d+)$")
repetitions = tonumber(repetitions) repetitions = tonumber(repetitions)
if axis == "?" then if axis == "?" then
axis, sign = worldedit.player_axis(name) axis, sign = worldedit.player_axis(name)
repetitions = repetitions * sign repetitions = repetitions * sign
end end
local count = worldedit.stack(pos1, pos2, axis, repetitions) local count = worldedit.stack(worldedit.pos1[name], worldedit.pos2[name], axis, repetitions)
worldedit.player_notify(name, count .. " nodes stacked") worldedit.player_notify(name, count .. " nodes stacked")
end, end,
function(name, param) function(name, param)
@ -649,7 +653,7 @@ minetest.register_chatcommand("/stack2", {
function() worldedit.player_notify(name, count .. " nodes stacked") end) function() worldedit.player_notify(name, count .. " nodes stacked") end)
end, function() end, function()
return count return count
end)(name,param) -- more hax end)(name,param) -- more hax --wip: clean this up a little bit
end end
}) })
@ -726,9 +730,8 @@ minetest.register_chatcommand("/flip", {
description = "Flip the current WorldEdit region along the x/y/z/? axis", description = "Flip the current WorldEdit region along the x/y/z/? axis",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if param == "?" then param = worldedit.player_axis(name) end if param == "?" then param = worldedit.player_axis(name) end
local count = worldedit.flip(pos1, pos2, param) local count = worldedit.flip(worldedit.pos1[name], worldedit.pos2[name], param)
worldedit.player_notify(name, count .. " nodes flipped") worldedit.player_notify(name, count .. " nodes flipped")
end, end,
function(name, param) function(name, param)
@ -777,9 +780,8 @@ minetest.register_chatcommand("/orient", {
description = "Rotate oriented nodes in the current WorldEdit region around the Y axis by angle <angle> (90 degree increment)", description = "Rotate oriented nodes in the current WorldEdit region around the Y axis by angle <angle> (90 degree increment)",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local found, _, angle = param:find("^([+-]?%d+)$") local found, _, angle = param:find("^([+-]?%d+)$")
local count = worldedit.orient(pos1, pos2, angle) local count = worldedit.orient(worldedit.pos1[name], worldedit.pos2[name], angle)
worldedit.player_notify(name, count .. " nodes oriented") worldedit.player_notify(name, count .. " nodes oriented")
end, end,
function(name, param) function(name, param)
@ -801,8 +803,7 @@ minetest.register_chatcommand("/fixlight", {
description = "Fix the lighting in the current WorldEdit region", description = "Fix the lighting in the current WorldEdit region",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] local count = worldedit.fixlight(worldedit.pos1[name], worldedit.pos2[name])
local count = worldedit.fixlight(pos1, pos2)
worldedit.player_notify(name, count .. " nodes updated") worldedit.player_notify(name, count .. " nodes updated")
end), end),
}) })
@ -812,8 +813,7 @@ minetest.register_chatcommand("/hide", {
description = "Hide all nodes in the current WorldEdit region non-destructively", description = "Hide all nodes in the current WorldEdit region non-destructively",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] local count = worldedit.hide(worldedit.pos1[name], worldedit.pos2[name])
local count = worldedit.hide(pos1, pos2)
worldedit.player_notify(name, count .. " nodes hidden") worldedit.player_notify(name, count .. " nodes hidden")
end), end),
}) })
@ -823,9 +823,8 @@ minetest.register_chatcommand("/suppress", {
description = "Suppress all <node> in the current WorldEdit region non-destructively", description = "Suppress all <node> in the current WorldEdit region non-destructively",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local node = get_node(name, param) local node = get_node(name, param)
local count = worldedit.suppress(pos1, pos2, node) local count = worldedit.suppress(worldedit.pos1[name], worldedit.pos2[name], node)
worldedit.player_notify(name, count .. " nodes suppressed") worldedit.player_notify(name, count .. " nodes suppressed")
end, check_set), end, check_set),
}) })
@ -835,9 +834,8 @@ minetest.register_chatcommand("/highlight", {
description = "Highlight <node> in the current WorldEdit region by hiding everything else non-destructively", description = "Highlight <node> in the current WorldEdit region by hiding everything else non-destructively",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local node = get_node(name, param) local node = get_node(name, param)
local count = worldedit.highlight(pos1, pos2, node) local count = worldedit.highlight(worldedit.pos1[name], worldedit.pos2[name], node)
worldedit.player_notify(name, count .. " nodes highlighted") worldedit.player_notify(name, count .. " nodes highlighted")
end, check_set), end, check_set),
}) })
@ -847,8 +845,7 @@ minetest.register_chatcommand("/restore", {
description = "Restores nodes hidden with WorldEdit in the current WorldEdit region", description = "Restores nodes hidden with WorldEdit in the current WorldEdit region",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] local count = worldedit.restore(worldedit.pos1[name], worldedit.pos2[name])
local count = worldedit.restore(pos1, pos2)
worldedit.player_notify(name, count .. " nodes restored") worldedit.player_notify(name, count .. " nodes restored")
end), end),
}) })
@ -858,7 +855,6 @@ minetest.register_chatcommand("/save", {
description = "Save the current WorldEdit region to \"(world folder)/schems/<file>.we\"", description = "Save the current WorldEdit region to \"(world folder)/schems/<file>.we\"",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if param == "" then if param == "" then
worldedit.player_notify(name, "invalid usage: " .. param) worldedit.player_notify(name, "invalid usage: " .. param)
return return
@ -868,7 +864,7 @@ minetest.register_chatcommand("/save", {
return return
end end
local result, count = worldedit.serialize(pos1, pos2) local result, count = worldedit.serialize(worldedit.pos1[name], worldedit.pos2[name])
local path = minetest.get_worldpath() .. "/schems" local path = minetest.get_worldpath() .. "/schems"
local filename = path .. "/" .. param .. ".we" local filename = path .. "/" .. param .. ".we"
@ -1000,14 +996,13 @@ minetest.register_chatcommand("/luatransform", {
description = "Executes <code> as a Lua chunk in the global namespace with the variable pos available, for each node in the current WorldEdit region", description = "Executes <code> as a Lua chunk in the global namespace with the variable pos available, for each node in the current WorldEdit region",
privs = {worldedit=true, server=true}, privs = {worldedit=true, server=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local admin = minetest.setting_get("name") local admin = minetest.setting_get("name")
if not admin or not name == admin then if not admin or not name == admin then
worldedit.player_notify(name, "this command can only be run by the server administrator") worldedit.player_notify(name, "this command can only be run by the server administrator")
return return
end end
local err = worldedit.luatransform(pos1, pos2, param) local err = worldedit.luatransform(worldedit.pos1[name], worldedit.pos2[name], param)
if err then if err then
worldedit.player_notify(name, "code error: " .. err, false) worldedit.player_notify(name, "code error: " .. err, false)
else else
@ -1021,7 +1016,6 @@ minetest.register_chatcommand("/mtschemcreate", {
description = "Save the current WorldEdit region using the Minetest Schematic format to \"(world folder)/schems/<filename>.mts\"", description = "Save the current WorldEdit region using the Minetest Schematic format to \"(world folder)/schems/<filename>.mts\"",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if param == nil then if param == nil then
worldedit.player_notify(name, "No filename specified") worldedit.player_notify(name, "No filename specified")
return return
@ -1032,7 +1026,7 @@ minetest.register_chatcommand("/mtschemcreate", {
filename = filename:gsub("\"", "\\\""):gsub("\\", "\\\\") --escape any nasty characters filename = filename:gsub("\"", "\\\""):gsub("\\", "\\\\") --escape any nasty characters
os.execute("mkdir \"" .. path .. "\"") --create directory if it does not already exist os.execute("mkdir \"" .. path .. "\"") --create directory if it does not already exist
local ret = minetest.create_schematic(pos1, pos2, worldedit.prob_list[name], filename) local ret = minetest.create_schematic(worldedit.pos1[name], worldedit.pos2[name], worldedit.prob_list[name], filename)
if ret == nil then if ret == nil then
worldedit.player_notify(name, "failed to create Minetest schematic", false) worldedit.player_notify(name, "failed to create Minetest schematic", false)
else else
@ -1111,8 +1105,7 @@ minetest.register_chatcommand("/clearobjects", {
description = "Clears all objects within the WorldEdit region", description = "Clears all objects within the WorldEdit region",
privs = {worldedit=true}, privs = {worldedit=true},
func = safe_region(function(name, param) func = safe_region(function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] local count = worldedit.clearobjects(worldedit.pos1[name], worldedit.pos2[name])
local count = worldedit.clearobjects(pos1, pos2)
worldedit.player_notify(name, count .. " objects cleared") worldedit.player_notify(name, count .. " objects cleared")
end), end),
}) })