add howlight command

This commit is contained in:
poikilos 2019-06-05 14:52:46 -04:00
parent ad4dffe594
commit 14021606d5
2 changed files with 25 additions and 7 deletions

17
chatcommands.lua Normal file
View File

@ -0,0 +1,17 @@
minetest.register_chatcommand("howlight", {
description = "Show the light level of the ground below you",
func = function(name)
local player = minetest.get_player_by_name(name)
if player then
local player_pos = vector.round(player:get_pos())
-- local pos = vector.new(player_pos.x, player_pos.y - 1 , player_pos.z)
local pos = player_pos
-- underground, light is always zero, so z-1 doesn't work.
local pos_string = minetest.pos_to_string(pos)
minetest.chat_send_player(name, "Light level at " .. pos_string .. " is " .. minetest.get_node_light(pos) .. ".")
return true
else
return false, "You are not connected to minetestserver."
end
end
})

View File

@ -20,6 +20,7 @@ local nodelock = {}
local modpath = minetest.get_modpath("metatools")
dofile(modpath .. "/assertions.lua")
dofile(modpath .. "/chatcommands.lua")
minetest.register_craftitem("metatools:stick",{
description = "Meta stick",