init.lua 707 B

123456789101112131415161718192021222324
  1. if not minetest.global_exists("itemstring") then itemstring = {} end
  2. itemstring.modpath = minetest.get_modpath("itemstring")
  3. minetest.register_privilege("item_info", {
  4. description = "User can get wielded item info.",
  5. give_to_singleplayer = false,
  6. })
  7. minetest.register_chatcommand("item-string", {
  8. params = "",
  9. description = "Get the item-string of a wielded item.",
  10. privs = {item_info=true},
  11. func = function(name, param)
  12. local player = minetest.get_player_by_name(name)
  13. if not player then return end
  14. if not player:is_player() then return end
  15. local info = player:get_wielded_item():to_string()
  16. minetest.chat_send_player(name, "# Server: Wielded: '" .. info .. "'.")
  17. return true
  18. end
  19. })