From 0fddd17f23844b23ed3996f0a95c9acc2d3854a2 Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Sun, 21 Jul 2013 17:16:29 -0400 Subject: [PATCH] Add the node inspector, a tool for finding information about nodes. Configurable via the //inspect command. --- Chat Commands.md | 15 +++++++++++++++ worldedit_commands/init.lua | 33 +++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/Chat Commands.md b/Chat Commands.md index 6bd1772..08adbaf 100644 --- a/Chat Commands.md +++ b/Chat Commands.md @@ -2,6 +2,21 @@ Chat Commands ------------- For more information, see the [README](README.md). +### //inspect + +Enable or disable node inspection. + + //inspect on + //inspect off + //inspect 1 + //inspect 0 + //inspect true + //inspect false + //inspect yes + //inspect no + //inspect enable + //inspect disable + ### //reset Reset the region so that it is empty. diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index d75fdbf..3ef247d 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -49,6 +49,32 @@ worldedit.player_axis = function(name) return "z", dir.z > 0 and 1 or -1 end +worldedit.inspect = true + +minetest.register_chatcommand("/inspect", { + params = "on/off/1/0/true/false/yes/no/enable/disable", + description = "Enable or disable node inspection", + privs = {worldedit=true}, + func = function(name, param) + if param == "on" or param == "1" or param == "true" or param == "yes" or param == "enable" then + worldedit.inspect = true + worldedit.player_notify(name, "node inspection is now on") + elseif param == "off" or param == "0" or param == "false" or param == "no" or param == "disable" then + worldedit.inspect = false + worldedit.player_notify(name, "node inspection is now off") + else + worldedit.player_notify(name, "invalid usage: " .. param) + end + end, +}) + +minetest.register_on_punchnode(function(pos, node, puncher) + if worldedit.inspect then + message = "node inspector: " .. node.name .. " at " .. minetest.pos_to_string(pos) .. " (param1=" .. node.param1 .. ", param2=" .. node.param2 .. ")" + worldedit.player_notify(puncher:get_player_name(), message) + end +end) + minetest.register_chatcommand("/reset", { params = "", description = "Reset the region so that it is empty", @@ -205,12 +231,7 @@ minetest.register_chatcommand("/set", { return end - local tenv = minetest.env - if worldedit.ENABLE_QUEUE then - tenv = worldedit.queue_aliasenv - end - - local count = worldedit.set(pos1, pos2, node, tenv) + local count = worldedit.set(pos1, pos2, node) worldedit.player_notify(name, count .. " nodes set") end, })