Skip to content

Commit 426f3b9

Browse files
committedJan 26, 2017
Show light level a node receives with //inspect, fixes #128
1 parent 78e4ba8 commit 426f3b9

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed
 

Diff for: ‎worldedit_commands/init.lua

+18-2
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,28 @@ minetest.register_chatcommand("/inspect", {
162162
end,
163163
})
164164

165+
local function get_node_rlight(pos)
166+
local vecs = { -- neighboring nodes
167+
{x= 1, y= 0, z= 0},
168+
{x=-1, y= 0, z= 0},
169+
{x= 0, y= 1, z= 0},
170+
{x= 0, y=-1, z= 0},
171+
{x= 0, y= 0, z= 1},
172+
{x= 0, y= 0, z=-1},
173+
}
174+
local ret = 0
175+
for _, v in ipairs(vecs) do
176+
ret = math.max(ret, minetest.get_node_light(vector.add(pos, v)))
177+
end
178+
return ret
179+
end
180+
165181
minetest.register_on_punchnode(function(pos, node, puncher)
166182
local name = puncher:get_player_name()
167183
if worldedit.inspect[name] then
168184
local axis, sign = worldedit.player_axis(name)
169-
message = string.format("inspector: %s at %s (param1=%d, param2=%d, light=%d) punched facing the %s axis",
170-
node.name, minetest.pos_to_string(pos), node.param1, node.param2, minetest.get_node_light(pos), axis .. (sign > 0 and "+" or "-"))
185+
message = string.format("inspector: %s at %s (param1=%d, param2=%d, received light=%d) punched facing the %s axis",
186+
node.name, minetest.pos_to_string(pos), node.param1, node.param2, get_node_rlight(pos), axis .. (sign > 0 and "+" or "-"))
171187
worldedit.player_notify(name, message)
172188
end
173189
end)

0 commit comments

Comments
 (0)
Please sign in to comment.