From 7ce20dbfcef081c99ace447b3a269f27b2ade242 Mon Sep 17 00:00:00 2001 From: cornernote Date: Thu, 20 Sep 2012 13:56:14 +0930 Subject: [PATCH] added metasave/metaload to chat commands --- init.lua | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) 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 = "", + description = "Save the current WorldEdit region to \"(world folder)/schems/.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 = "", + description = "Load nodes from \"(world folder)/schems/.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, +})