Skip to content

Commit

Permalink
Show light level a node receives with //inspect, fixes #128
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Jan 26, 2017
1 parent 78e4ba8 commit 426f3b9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions worldedit_commands/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 426f3b9

Please sign in to comment.