/gist:3ff0042f0459560e0722 Secret
Last active
April 5, 2019 20:52
Minetest - Metadata spy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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