diff --git a/src/client/luafunctions.cpp b/src/client/luafunctions.cpp index 0c04f54c..578c3ae9 100644 --- a/src/client/luafunctions.cpp +++ b/src/client/luafunctions.cpp @@ -67,8 +67,10 @@ void Client::registerLuaFunctions() g_lua.bindSingletonFunction("g_things", "getThingTypes", &ThingTypeManager::getThingTypes, &g_things); g_lua.bindSingletonFunction("g_things", "findItemTypeByClientId", &ThingTypeManager::findItemTypeByClientId, &g_things); g_lua.bindSingletonFunction("g_things", "findItemTypeByName", &ThingTypeManager::findItemTypeByName, &g_things); - g_lua.bindSingletonFunction("g_things", "findThingTypeByAttr", &ThingTypeManager::findThingTypeByAttr, &g_things); + g_lua.bindSingletonFunction("g_things", "findItemTypesByName", &ThingTypeManager::findItemTypesByName, &g_things); + g_lua.bindSingletonFunction("g_things", "findItemTypesByString", &ThingTypeManager::findItemTypesByString, &g_things); g_lua.bindSingletonFunction("g_things", "findItemTypeByCategory", &ThingTypeManager::findItemTypeByCategory, &g_things); + g_lua.bindSingletonFunction("g_things", "findThingTypeByAttr", &ThingTypeManager::findThingTypeByAttr, &g_things); g_lua.registerSingletonClass("g_houses"); g_lua.bindSingletonFunction("g_houses", "clear", &HouseManager::clear, &g_houses); diff --git a/src/client/thingtypemanager.cpp b/src/client/thingtypemanager.cpp index c43105c1..f839add6 100644 --- a/src/client/thingtypemanager.cpp +++ b/src/client/thingtypemanager.cpp @@ -299,6 +299,24 @@ const ItemTypePtr& ThingTypeManager::findItemTypeByName(std::string name) return m_nullItemType; } +ItemTypeList ThingTypeManager::findItemTypesByName(std::string name) +{ + ItemTypeList ret; + for(const ItemTypePtr& it : m_itemTypes) + if(it->getName() == name) + ret.push_back(it); + return ret; +} + +ItemTypeList ThingTypeManager::findItemTypesByString(std::string name) +{ + ItemTypeList ret; + for(const ItemTypePtr& it : m_itemTypes) + if(it->getName().find(name) != std::string::npos) + ret.push_back(it); + return ret; +} + const ThingTypePtr& ThingTypeManager::getThingType(uint16 id, ThingCategory category) { if(category >= ThingLastCategory || id >= m_thingTypes[category].size()) { diff --git a/src/client/thingtypemanager.h b/src/client/thingtypemanager.h index d89b0019..055d5c48 100644 --- a/src/client/thingtypemanager.h +++ b/src/client/thingtypemanager.h @@ -44,6 +44,8 @@ public: void addItemType(const ItemTypePtr& itemType); const ItemTypePtr& findItemTypeByClientId(uint16 id); const ItemTypePtr& findItemTypeByName(std::string name); + ItemTypeList findItemTypesByName(std::string name); + ItemTypeList findItemTypesByString(std::string str); const ThingTypePtr& getNullThingType() { return m_nullThingType; } const ItemTypePtr& getNullItemType() { return m_nullItemType; }