add howlight command
This commit is contained in:
parent
ad4dffe594
commit
14021606d5
17
chatcommands.lua
Normal file
17
chatcommands.lua
Normal 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
|
||||||
|
})
|
1
init.lua
1
init.lua
@ -20,6 +20,7 @@ local nodelock = {}
|
|||||||
|
|
||||||
local modpath = minetest.get_modpath("metatools")
|
local modpath = minetest.get_modpath("metatools")
|
||||||
dofile(modpath .. "/assertions.lua")
|
dofile(modpath .. "/assertions.lua")
|
||||||
|
dofile(modpath .. "/chatcommands.lua")
|
||||||
|
|
||||||
minetest.register_craftitem("metatools:stick",{
|
minetest.register_craftitem("metatools:stick",{
|
||||||
description = "Meta stick",
|
description = "Meta stick",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user