Skip to content

Instantly share code, notes, and snippets.

@kaeza
Last active April 5, 2019 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaeza/3ff0042f0459560e0722 to your computer and use it in GitHub Desktop.
Save kaeza/3ff0042f0459560e0722 to your computer and use it in GitHub Desktop.
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