From 89893df9ba50add97b02e59d7359e4e161a031e1 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Thu, 9 Apr 2015 14:39:11 +0200 Subject: [PATCH] Added itemdb command into _miscs - Added itemdb command to get an item's itemstring --- mods/_misc/chatcommands.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mods/_misc/chatcommands.lua b/mods/_misc/chatcommands.lua index 33847095..82964ebe 100755 --- a/mods/_misc/chatcommands.lua +++ b/mods/_misc/chatcommands.lua @@ -20,6 +20,7 @@ -- /rollback_check -- /rollback -- /status +-- /itemdb minetest.register_chatcommand("time", { params = "<0...24000>", @@ -69,6 +70,30 @@ minetest.register_chatcommand("ban", { end, }) +minetest.register_chatcommand("itemdb", { + params = "", + description = "Give itemstring of wielded item", + privs = {}, + func = function(name) + local player = minetest.get_player_by_name(name) + if not player then return false end + local item = player:get_wielded_item() + + if item:get_name() == "" then + minetest.chat_send_player(name,"You're handling nothing.") + return true + else + if not minetest.registered_items[item:get_name()] then + minetest.chat_send_player(name,"You are handling an unknown item (known before as " .. item:get_name() ..").") + return true + else + minetest.chat_send_player(name,"You are handling a " .. minetest.registered_items[item:get_name()].description .. " also known as " .. item:get_name() .. ".") + return true + end + end + end +}) + -- /unban -- /kick -- /clearobjects