From aa4a70d237db22b587d46a50a21d1a71a445874e Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Sun, 21 Oct 2012 17:49:43 -0400 Subject: Rename //find to //highlight and worldedit.find to worldedit.highlight, add //allocate and worldedit.allocate as well as related documentation. Improve documentation by fixing a few mistakes and adding return signatures. --- worldedit_commands/init.lua | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'worldedit_commands/init.lua') diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 1fb59d3..3931df0 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -567,9 +567,9 @@ minetest.register_chatcommand("/hide", { end, }) -minetest.register_chatcommand("/find", { +minetest.register_chatcommand("/highlight", { params = "", - description = "Find in the current WorldEdit region by hiding everything else non-destructively", + description = "Highlight in the current WorldEdit region by hiding everything else non-destructively", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] @@ -583,8 +583,8 @@ minetest.register_chatcommand("/find", { return end - local count = worldedit.find(pos1, pos2, param) - minetest.chat_send_player(name, count .. " nodes found") + local count = worldedit.highlight(pos1, pos2, param) + minetest.chat_send_player(name, count .. " nodes highlighted") end, }) @@ -638,6 +638,42 @@ minetest.register_chatcommand("/save", { end, }) +minetest.register_chatcommand("/allocate", { + params = "", + description = "Set the region defined by nodes from \"(world folder)/schems/.we\" as the current WorldEdit region", + 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 filename = minetest.get_worldpath() .. "/schems/" .. param .. ".we" + local file, err = io.open(filename, "rb") + if err ~= nil then + minetest.chat_send_player(name, "Could not open file \"" .. filename .. "\"") + return + end + local value = file:read("*a") + file:close() + + local nodepos1, nodepos2, count = worldedit.allocate(pos1, value) + + worldedit.pos1[name] = nodepos1 + worldedit.mark_pos1(name) + worldedit.pos2[name] = nodepos2 + worldedit.mark_pos2(name) + + minetest.chat_send_player(name, count .. " nodes allocated") + end, +}) + minetest.register_chatcommand("/load", { params = "", description = "Load nodes from \"(world folder)/schems/.we\" with position 1 of the current WorldEdit region as the origin", -- cgit v1.2.3