summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2017-01-26 22:26:45 +0100
committersfan5 <sfan5@live.de>2017-01-26 22:27:30 +0100
commit426f3b949fc48862f3b9b8368aa33147c805142b (patch)
tree0b6897ce53c316894f5e6d66159aa9c6c1b1f724
parent78e4ba828ebe19dc80977ce53ce301d63230b8b8 (diff)
Show light level a node receives with //inspect, fixes #128
-rw-r--r--worldedit_commands/init.lua20
1 files changed, 18 insertions, 2 deletions
diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua
index d47c6e2..3532343 100644
--- a/worldedit_commands/init.lua
+++ b/worldedit_commands/init.lua
@@ -162,12 +162,28 @@ minetest.register_chatcommand("/inspect", {
end,
})
+local function get_node_rlight(pos)
+ local vecs = { -- neighboring nodes
+ {x= 1, y= 0, z= 0},
+ {x=-1, y= 0, z= 0},
+ {x= 0, y= 1, z= 0},
+ {x= 0, y=-1, z= 0},
+ {x= 0, y= 0, z= 1},
+ {x= 0, y= 0, z=-1},
+ }
+ local ret = 0
+ for _, v in ipairs(vecs) do
+ ret = math.max(ret, minetest.get_node_light(vector.add(pos, v)))
+ end
+ return ret
+end
+
minetest.register_on_punchnode(function(pos, node, puncher)
local name = puncher:get_player_name()
if worldedit.inspect[name] then
local axis, sign = worldedit.player_axis(name)
- message = string.format("inspector: %s at %s (param1=%d, param2=%d, light=%d) punched facing the %s axis",
- node.name, minetest.pos_to_string(pos), node.param1, node.param2, minetest.get_node_light(pos), axis .. (sign > 0 and "+" or "-"))
+ message = string.format("inspector: %s at %s (param1=%d, param2=%d, received light=%d) punched facing the %s axis",
+ node.name, minetest.pos_to_string(pos), node.param1, node.param2, get_node_rlight(pos), axis .. (sign > 0 and "+" or "-"))
worldedit.player_notify(name, message)
end
end)