summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcornernote <cornernote@gmail.com>2012-09-20 13:56:14 +0930
committercornernote <cornernote@gmail.com>2012-09-20 13:56:14 +0930
commit7ce20dbfcef081c99ace447b3a269f27b2ade242 (patch)
tree04a1ae860e812aea15af34525ee174cd7097d91f
parentc8cfd524ddddbeb055866cd2d8c6b10453c00c6a (diff)
added metasave/metaload to chat commands
-rw-r--r--init.lua46
1 files changed, 46 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index 32bf8e2..1e9b0ef 100644
--- a/init.lua
+++ b/init.lua
@@ -529,3 +529,49 @@ minetest.register_chatcommand("/load", {
minetest.chat_send_player(name, count .. " nodes loaded")
end,
})
+
+minetest.register_chatcommand("/metasave", {
+ params = "<file>",
+ description = "Save the current WorldEdit region to \"(world folder)/schems/<file>.wem\"",
+ 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 param == "" then
+ minetest.chat_send_player(name, "Invalid usage: " .. param)
+ return
+ end
+ local count, err = worldedit.metasave(pos1, pos2, param)
+ if err then
+ minetest.chat_send_player(name, "error loading file: " .. err)
+ else
+ minetest.chat_send_player(name, count .. " nodes saved")
+ end
+ end,
+})
+
+minetest.register_chatcommand("/metaload", {
+ params = "<file>",
+ description = "Load nodes from \"(world folder)/schems/<file>.wem\" with position 1 of the current WorldEdit region as the origin",
+ privs = {worldedit=true},
+ func = function(name, param)
+ local pos1 = worldedit.pos1[name]
+ if pos1 == nil then
+ minetest.chat_send_player(name, "No WorldEdit region selected")
+ return
+ end
+ if param == "" then
+ minetest.chat_send_player(name, "Invalid usage: " .. param)
+ return
+ end
+ local count, err = worldedit.metaload(pos1, param)
+ if err then
+ minetest.chat_send_player(name, "error loading file: " .. err)
+ else
+ minetest.chat_send_player(name, count .. " nodes loaded")
+ end
+ end,
+})