]> git.lizzy.rs Git - worldedit.git/commitdiff
Show light level a node receives with //inspect, fixes #128
authorsfan5 <sfan5@live.de>
Thu, 26 Jan 2017 21:26:45 +0000 (22:26 +0100)
committersfan5 <sfan5@live.de>
Thu, 26 Jan 2017 21:27:30 +0000 (22:27 +0100)
worldedit_commands/init.lua

index d47c6e27c64f4848bd9bad119012bb98e735b3bd..353234356a05a71d55aa62e0761f5f6339c360c5 100644 (file)
@@ -162,12 +162,28 @@ minetest.register_chatcommand("/inspect", {
        end,\r
 })\r
 \r
+local function get_node_rlight(pos)\r
+       local vecs = { -- neighboring nodes\r
+               {x= 1, y= 0, z= 0},\r
+               {x=-1, y= 0, z= 0},\r
+               {x= 0, y= 1, z= 0},\r
+               {x= 0, y=-1, z= 0},\r
+               {x= 0, y= 0, z= 1},\r
+               {x= 0, y= 0, z=-1},\r
+       }\r
+       local ret = 0\r
+       for _, v in ipairs(vecs) do\r
+               ret = math.max(ret, minetest.get_node_light(vector.add(pos, v)))\r
+       end\r
+       return ret\r
+end\r
+\r
 minetest.register_on_punchnode(function(pos, node, puncher)\r
        local name = puncher:get_player_name()\r
        if worldedit.inspect[name] then\r
                local axis, sign = worldedit.player_axis(name)\r
-               message = string.format("inspector: %s at %s (param1=%d, param2=%d, light=%d) punched facing the %s axis",\r
-                       node.name, minetest.pos_to_string(pos), node.param1, node.param2, minetest.get_node_light(pos), axis .. (sign > 0 and "+" or "-"))\r
+               message = string.format("inspector: %s at %s (param1=%d, param2=%d, received light=%d) punched facing the %s axis",\r
+                       node.name, minetest.pos_to_string(pos), node.param1, node.param2, get_node_rlight(pos), axis .. (sign > 0 and "+" or "-"))\r
                worldedit.player_notify(name, message)\r
        end\r
 end)\r