summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorPaul Ouellette <oue.paul18@gmail.com>2019-08-24 12:38:02 -0400
committersfan5 <sfan5@live.de>2019-08-24 18:38:02 +0200
commit008b80fe1ca9d46610b8971e2ac92fb56da8e69f (patch)
tree581fb878e5b5afe163c12dfc926158b9f0e5b0a8 /src/inventory.cpp
parentefbac7e4466ebc576b2cc64b5b782c61136cde66 (diff)
downloadminetest-008b80fe1ca9d46610b8971e2ac92fb56da8e69f.tar.gz
minetest-008b80fe1ca9d46610b8971e2ac92fb56da8e69f.tar.bz2
minetest-008b80fe1ca9d46610b8971e2ac92fb56da8e69f.zip
Add ItemStack:get_description() to get tooltip (#8847)
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 40dc602d0..f2cc2ede3 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -246,6 +246,14 @@ std::string ItemStack::getItemString() const
return os.str();
}
+std::string ItemStack::getDescription(IItemDefManager *itemdef) const
+{
+ std::string desc = metadata.getString("description");
+ if (desc.empty())
+ desc = getDefinition(itemdef).description;
+ return desc.empty() ? name : desc;
+}
+
ItemStack ItemStack::addItem(ItemStack newitem, IItemDefManager *itemdef)
{