summaryrefslogtreecommitdiff
path: root/worldedit_commands
diff options
context:
space:
mode:
authorAnthony Zhang <azhang9@gmail.com>2013-01-12 18:20:41 -0500
committerAnthony Zhang <azhang9@gmail.com>2013-01-12 18:20:41 -0500
commite2f1c4ef174443b2807aa94a209261546bbf19fb (patch)
tree8e81c6141d2b7823b1112308fbddcfed1b2df2b1 /worldedit_commands
parentc27ab877f1bc8afde76f9cfe11c7880cec9bdda2 (diff)
Add //homogenize, //lua, and //luatransform commands, as well as their documentation.
Diffstat (limited to 'worldedit_commands')
-rw-r--r--worldedit_commands/init.lua59
1 files changed, 57 insertions, 2 deletions
diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua
index 15220c6..a2e6246 100644
--- a/worldedit_commands/init.lua
+++ b/worldedit_commands/init.lua
@@ -169,7 +169,7 @@ minetest.register_chatcommand("/set", {
minetest.register_chatcommand("/replace", {
params = "<search node> <replace node>",
- description = "Replace all instances of <search node> with <place node> in the current WorldEdit region",
+ description = "Replace all instances of <search node> with <replace node> in the current WorldEdit region",
privs = {worldedit=true},
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
@@ -197,6 +197,27 @@ minetest.register_chatcommand("/replace", {
end,
})
+minetest.register_chatcommand("/homogenize", {
+ params = "<node>",
+ description = "Replace all non-air nodes with <node> in the current WorldEdit region",
+ privs = {worldedit=true},
+ func = function(name, param)
+ local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
+ if pos1 == nil or pos2 == nil then
+ minetest.chat_send_player(name, "No WorldEdit region selected")
+ return
+ end
+
+ if not worldedit.node_is_valid(param) then
+ minetest.chat_send_player(name, "Invalid node name: " .. param)
+ return
+ end
+
+ local count = worldedit.homogenize(pos1, pos2, param)
+ minetest.chat_send_player(name, count .. " nodes homogenized")
+ end,
+})
+
minetest.register_chatcommand("/hollowsphere", {
params = "<radius> <node>",
description = "Add hollow sphere at WorldEdit position 1 with radius <radius>, composed of <node>",
@@ -811,9 +832,43 @@ minetest.register_chatcommand("/metaload", {
end
local count, err = worldedit.metaload(pos1, param)
if err then
- minetest.chat_send_player(name, "error loading file: " .. err)
+ minetest.chat_send_player(name, "Error loading file: " .. err)
else
minetest.chat_send_player(name, count .. " nodes loaded")
end
end,
})
+
+minetest.register_chatcommand("/lua", {
+ params = "<code>",
+ description = "Executes <code> as a Lua chunk in the global namespace",
+ privs = {worldedit=true},
+ func = function(name, param)
+ local err = worldedit.lua(param)
+ if err then
+ minetest.chat_send_player(name, "Code error: " .. err)
+ else
+ minetest.chat_send_player(name, "Code successfully executed")
+ end
+ end,
+})
+
+minetest.register_chatcommand("/luatransform", {
+ params = "<code>",
+ 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},
+ func = function(name, param)
+ local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
+ if pos1 == nil or pos2 == nil then
+ minetest.chat_send_player(name, "No WorldEdit region selected")
+ return
+ end
+
+ local err = worldedit.luatransform(pos1, pos2, param)
+ if err then
+ minetest.chat_send_player(name, "Code error: " .. err)
+ else
+ minetest.chat_send_player(name, "Code successfully executed")
+ end
+ end,
+}) \ No newline at end of file