diff --git a/src/lua/functions/items/item_functions.cpp b/src/lua/functions/items/item_functions.cpp index 5b3802377bb..80e5bed4ce1 100644 --- a/src/lua/functions/items/item_functions.cpp +++ b/src/lua/functions/items/item_functions.cpp @@ -848,6 +848,20 @@ int ItemFunctions::luaItemIsInsideDepot(lua_State* L) { return 1; } +int ItemFunctions::luaItemIsContainer(lua_State* L) { + // item:isContainer() + auto const item = getUserdata(L, 1); + if (!item) { + reportErrorFunc(getErrorDesc(LUA_ERROR_ITEM_NOT_FOUND)); + pushBoolean(L, false); + return 1; + } + + const auto &it = Item::items[item->getID()]; + pushBoolean(L, it.isContainer()); + return 1; +} + int ItemFunctions::luaItemGetTier(lua_State* L) { // item:getTier() const Item* item = getUserdata(L, 1); diff --git a/src/lua/functions/items/item_functions.hpp b/src/lua/functions/items/item_functions.hpp index e890f2df1f7..a9100b2316a 100644 --- a/src/lua/functions/items/item_functions.hpp +++ b/src/lua/functions/items/item_functions.hpp @@ -75,6 +75,7 @@ class ItemFunctions final : LuaScriptInterface { registerMethod(L, "Item", "setDuration", ItemFunctions::luaItemSetDuration); registerMethod(L, "Item", "isInsideDepot", ItemFunctions::luaItemIsInsideDepot); + registerMethod(L, "Item", "isContainer", ItemFunctions::luaItemIsContainer); registerMethod(L, "Item", "getTier", ItemFunctions::luaItemGetTier); registerMethod(L, "Item", "setTier", ItemFunctions::luaItemSetTier); @@ -145,6 +146,7 @@ class ItemFunctions final : LuaScriptInterface { static int luaItemSetDuration(lua_State* L); static int luaItemIsInsideDepot(lua_State* L); + static int luaItemIsContainer(lua_State* L); static int luaItemGetTier(lua_State* L); static int luaItemSetTier(lua_State* L);