mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-05 01:03:44 +01:00
Use color for named items
parent
8ff92fcb7f
commit
197afa664b
@ -2,6 +2,7 @@ local MAX_NAME_LENGTH = 30
|
||||
local MAX_WEAR = 65535
|
||||
local SAME_TOOL_REPAIR_BOOST = math.ceil(MAX_WEAR * 0.12) -- 12%
|
||||
local MATERIAL_TOOL_REPAIR_BOOST = math.ceil(MAX_WEAR * 0.25) -- 25%
|
||||
local NAME_COLOR = "#FFFF4C"
|
||||
|
||||
local function get_anvil_formspec(set_name)
|
||||
if not set_name then
|
||||
@ -129,14 +130,19 @@ local function update_anvil_slots(meta)
|
||||
-- Don't rename if names are identical
|
||||
if new_name ~= old_name then
|
||||
-- Rename item
|
||||
if new_name == "" and name_item:get_definition()._mcl_generate_description then
|
||||
-- _mcl_generate_description(itemstack): If defined, set custom item description of itemstack.
|
||||
-- This function should be defined for items with an advanced description.
|
||||
-- See mcl_banners for an example.
|
||||
name_item:get_definition()._mcl_generate_description(name_item)
|
||||
if new_name == "" then
|
||||
-- Empty name
|
||||
if name_item:get_definition()._mcl_generate_description then
|
||||
-- _mcl_generate_description(itemstack): If defined, set custom item description of itemstack.
|
||||
name_item:get_definition()._mcl_generate_description(name_item)
|
||||
else
|
||||
-- Otherwise, just clear description
|
||||
meta:set_string("description", "")
|
||||
end
|
||||
else
|
||||
-- Set description
|
||||
meta:set_string("description", new_name)
|
||||
-- Custom name set. Colorize it!
|
||||
-- This makes the name visually different from unnamed items
|
||||
meta:set_string("description", core.colorize(NAME_COLOR, new_name))
|
||||
end
|
||||
-- Save the raw name internally, too
|
||||
meta:set_string("name", new_name)
|
||||
|
@ -279,6 +279,7 @@ for colorid, colortab in pairs(mcl_banners.colors) do
|
||||
local mname = imeta:get_string("name")
|
||||
if mname ~= nil and mname ~= "" then
|
||||
banner:get_luaentity()._item_name = mname
|
||||
banner:get_luaentity()._item_description = imeta:get_string("description")
|
||||
end
|
||||
|
||||
-- Set rotation
|
||||
@ -386,7 +387,7 @@ local entity_standing = {
|
||||
local meta = banner:get_meta()
|
||||
meta:set_string("layers", minetest.serialize(self._layers))
|
||||
if self._item_name ~= nil and self._item_name ~= "" then
|
||||
meta:set_string("description", self._item_name)
|
||||
meta:set_string("description", self._item_description)
|
||||
meta:set_string("name", self._item_name)
|
||||
else
|
||||
meta:set_string("description", mcl_banners.make_advanced_banner_description(banner:get_definition().description, self._layers))
|
||||
|
@ -471,7 +471,7 @@ local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_i
|
||||
local description = mcl_banners.make_advanced_banner_description(odesc, layers)
|
||||
imeta:set_string("description", description)
|
||||
else
|
||||
imeta:set_string("description", mname)
|
||||
imeta:set_string("description", ometa:get_string("description"))
|
||||
imeta:set_string("name", mname)
|
||||
end
|
||||
return itemstack
|
||||
|
Loading…
Reference in New Issue
Block a user