mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Add a short_description to be used by mods (#8980)
This commit is contained in:
@@ -56,6 +56,7 @@ void read_item_definition(lua_State* L, int index,
|
||||
es_ItemType, ITEM_NONE);
|
||||
getstringfield(L, index, "name", def.name);
|
||||
getstringfield(L, index, "description", def.description);
|
||||
getstringfield(L, index, "short_description", def.short_description);
|
||||
getstringfield(L, index, "inventory_image", def.inventory_image);
|
||||
getstringfield(L, index, "inventory_overlay", def.inventory_overlay);
|
||||
getstringfield(L, index, "wield_image", def.wield_image);
|
||||
@@ -142,6 +143,8 @@ void push_item_definition_full(lua_State *L, const ItemDefinition &i)
|
||||
lua_setfield(L, -2, "name");
|
||||
lua_pushstring(L, i.description.c_str());
|
||||
lua_setfield(L, -2, "description");
|
||||
lua_pushstring(L, i.short_description.c_str());
|
||||
lua_setfield(L, -2, "short_description");
|
||||
lua_pushstring(L, type.c_str());
|
||||
lua_setfield(L, -2, "type");
|
||||
lua_pushstring(L, i.inventory_image.c_str());
|
||||
|
@@ -193,6 +193,16 @@ int LuaItemStack::l_get_description(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get_short_description(self)
|
||||
int LuaItemStack::l_get_short_description(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
LuaItemStack *o = checkobject(L, 1);
|
||||
std::string desc = o->m_stack.getShortDescription(getGameDef(L)->idef());
|
||||
lua_pushstring(L, desc.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// clear(self) -> true
|
||||
int LuaItemStack::l_clear(lua_State *L)
|
||||
{
|
||||
@@ -493,6 +503,7 @@ const luaL_Reg LuaItemStack::methods[] = {
|
||||
luamethod(LuaItemStack, get_metadata),
|
||||
luamethod(LuaItemStack, set_metadata),
|
||||
luamethod(LuaItemStack, get_description),
|
||||
luamethod(LuaItemStack, get_short_description),
|
||||
luamethod(LuaItemStack, clear),
|
||||
luamethod(LuaItemStack, replace),
|
||||
luamethod(LuaItemStack, to_string),
|
||||
|
@@ -72,6 +72,9 @@ private:
|
||||
// get_description(self)
|
||||
static int l_get_description(lua_State *L);
|
||||
|
||||
// get_short_description(self)
|
||||
static int l_get_short_description(lua_State *L);
|
||||
|
||||
// clear(self) -> true
|
||||
static int l_clear(lua_State *L);
|
||||
|
||||
|
Reference in New Issue
Block a user