1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-14 00:55:20 +02:00

Add ItemStack:get_description() to get tooltip (#8847)

This commit is contained in:
Paul Ouellette
2019-08-24 12:38:02 -04:00
committed by sfan5
parent efbac7e446
commit 008b80fe1c
6 changed files with 33 additions and 22 deletions

View File

@@ -175,6 +175,16 @@ int LuaItemStack::l_set_metadata(lua_State *L)
return 1;
}
// get_description(self)
int LuaItemStack::l_get_description(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
LuaItemStack *o = checkobject(L, 1);
std::string desc = o->m_stack.getDescription(getGameDef(L)->idef());
lua_pushstring(L, desc.c_str());
return 1;
}
// clear(self) -> true
int LuaItemStack::l_clear(lua_State *L)
{
@@ -470,6 +480,7 @@ const luaL_Reg LuaItemStack::methods[] = {
luamethod(LuaItemStack, get_meta),
luamethod(LuaItemStack, get_metadata),
luamethod(LuaItemStack, set_metadata),
luamethod(LuaItemStack, get_description),
luamethod(LuaItemStack, clear),
luamethod(LuaItemStack, replace),
luamethod(LuaItemStack, to_string),

View File

@@ -66,6 +66,9 @@ private:
// set_metadata(self, string)
static int l_set_metadata(lua_State *L);
// get_description(self)
static int l_get_description(lua_State *L);
// clear(self) -> true
static int l_clear(lua_State *L);