Evergreen wrote:There should be a command which gets the pointed block and prints the node name into the chat.
I wanted to do a mod like that some time ago, but the problem is, that there is no way I know of on how to get the pointed node. (Except punching.)
For items in the inventory take this.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_chatcommand("getinfo_item", {
params = "",
description = "name of item in hand",
privs = {},
func = function(name, param)
local player = minetest.get_player_by_name(name)
if player == nil then
minetest.log("error", "Unable to get info, player is nil")
return true -- Handled chat message
end
if player:get_wielded_item():is_empty() then
minetest.chat_send_player(name, 'Unable to get info, no item in hand.')
else
local item_name = player:get_wielded_item():get_name()
local item_count = player:get_wielded_item():get_count()
local item_wear = player:get_wielded_item():get_wear()
minetest.chat_send_player(name, 'get info: name = '.. item_name ..', count = '.. item_count ..', wear = '.. item_wear ..'')
end
end,
})