Display true owner of wands and book

This commit is contained in:
Evert Prants 2019-11-23 21:18:05 +02:00
parent 220886d4a0
commit ef4b6ac8b7
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 12 additions and 2 deletions

View File

@ -233,14 +233,19 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return true return true
end) end)
local mgww = "Magicalities' Guide for Witches and Wizards"
minetest.register_craftitem("magicalities:book", { minetest.register_craftitem("magicalities:book", {
description = "Magicalities' Guide for Witches and Wizards", description = mgww,
inventory_image = "magicalities_book.png", inventory_image = "magicalities_book.png",
on_use = book_read, on_use = book_read,
on_place = book_read, on_place = book_read,
on_secondary_use = book_read, on_secondary_use = book_read,
_wand_created = function (itemstack, wand, user, pos) _wand_created = function (itemstack, wand, user, pos)
itemstack:get_meta():set_string("player", user:get_player_name()) local meta = itemstack:get_meta()
local name = user:get_player_name()
meta:set_string("player", name)
meta:set_string("description", mgww .. "\n" ..
minetest.colorize("#d33b57", string.format("Soulbound to %s", name)))
return itemstack return itemstack
end, end,
stack_max = 1 stack_max = 1

View File

@ -165,6 +165,11 @@ function magicalities.wands.update_wand_desc(stack)
strbld = strbld .. "\n" .. table.concat(elems, "\n") strbld = strbld .. "\n" .. table.concat(elems, "\n")
end end
local owner = meta:get_string("player")
if owner ~= "" then
strbld = strbld .. "\n" .. minetest.colorize("#d33b57", string.format("Soulbound to %s", owner))
end
meta:set_string("description", strbld) meta:set_string("description", strbld)
end end