Skip to content

Instantly share code, notes, and snippets.

@kaeza

kaeza/gist:3ff0042f0459560e0722 Secret

Last active Apr 5, 2019
Embed
What would you like to do?
Minetest - Metadata spy
minetest.register_craftitem("metaspy:metaspy", {
description = "Metadata Spy",
inventory_image = "default_wood",
on_use = function(itemstack, user, pointed_thing)
local plname = user:get_player_name()
local send = minetest.chat_send_player
if pointed_thing.type == "node" then
local meta = minetest.get_meta(pointed_thing.under):to_table()
if meta.fields then
send(plname, "METAFIELDS:")
for k, v in pairs(meta.fields) do
send(plname, (" %q = %q"):format(k, tostring(v)))
end
end
if meta.inventory then
send(plname, "INVENTORY LISTS:")
for k, v in pairs(meta.inventory) do
send(plname, (" %q (%d items)"):format(k, #v))
end
end
end
end,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment