diff options
-rw-r--r-- | doc/lua_api.txt | 4 | ||||
-rw-r--r-- | src/guiFormSpecMenu.cpp | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 2f5e3706c..dd20ae904 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1473,6 +1473,10 @@ Item stacks can store metadata too. See `ItemStackMetaRef`. Item metadata only contains a key-value store. +Some of the values in the key-value store are handled specially: + +* `description`: Set the itemstack's description. Defaults to idef.description + Example stuff: local meta = stack:get_meta() diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index 45b0e9c11..67b3a9ad0 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -2303,7 +2303,12 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase, // Draw tooltip std::wstring tooltip_text = L""; if (hovering && !m_selected_item) { - tooltip_text = utf8_to_wide(item.getDefinition(m_client->idef()).description); + const std::string &desc = item.metadata.getString("description"); + if (desc.empty()) + tooltip_text = + utf8_to_wide(item.getDefinition(m_client->idef()).description); + else + tooltip_text = utf8_to_wide(desc); } if (tooltip_text != L"") { std::vector<std::wstring> tt_rows = str_split(tooltip_text, L'\n'); |