mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add a short_description to be used by mods (#8980)
This commit is contained in:
parent
b2f3f66385
commit
f3ae45b2b2
11 changed files with 102 additions and 2 deletions
|
@ -258,6 +258,20 @@ std::string ItemStack::getDescription(IItemDefManager *itemdef) const
|
|||
return desc.empty() ? name : desc;
|
||||
}
|
||||
|
||||
std::string ItemStack::getShortDescription(IItemDefManager *itemdef) const
|
||||
{
|
||||
std::string desc = metadata.getString("short_description");
|
||||
if (desc.empty())
|
||||
desc = getDefinition(itemdef).short_description;
|
||||
if (!desc.empty())
|
||||
return desc;
|
||||
// no short_description because of old server version or modified builtin
|
||||
// return first line of description
|
||||
std::stringstream sstr(getDescription(itemdef));
|
||||
std::getline(sstr, desc, '\n');
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
||||
ItemStack ItemStack::addItem(ItemStack newitem, IItemDefManager *itemdef)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue