diff --git a/Client/mods/deathmatch/logic/CResourceManager.h b/Client/mods/deathmatch/logic/CResourceManager.h index d79bff256d..ecae877a99 100644 --- a/Client/mods/deathmatch/logic/CResourceManager.h +++ b/Client/mods/deathmatch/logic/CResourceManager.h @@ -39,6 +39,9 @@ class CResourceManager CResource* GetResourceFromLuaState(struct lua_State* luaVM); SString GetResourceName(struct lua_State* luaVM); + std::list::const_iterator IterBegin() { return m_resources.begin(); }; + std::list::const_iterator IterEnd() { return m_resources.end(); }; + bool RemoveResource(unsigned short usID); void Remove(CResource* pResource); bool Exists(CResource* pResource); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaResourceDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaResourceDefs.cpp index 265c6383b1..8c6ba93ce8 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaResourceDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaResourceDefs.cpp @@ -26,6 +26,7 @@ void CLuaResourceDefs::LoadFunctions() {"getResourceGUIElement", GetResourceGUIElement}, {"getResourceDynamicElementRoot", GetResourceDynamicElementRoot}, {"getResourceExportedFunctions", GetResourceExportedFunctions}, + {"getResources", GetResources}, {"getResourceState", GetResourceState}, {"loadstring", LoadString}, {"load", Load}, @@ -391,6 +392,20 @@ int CLuaResourceDefs::GetResourceExportedFunctions(lua_State* luaVM) return 1; } +int CLuaResourceDefs::GetResources(lua_State* luaVM) +{ + unsigned int uiIndex = 0; + lua_newtable(luaVM); + list::const_iterator iter = m_pResourceManager->IterBegin(); + for (; iter != m_pResourceManager->IterEnd(); ++iter) + { + lua_pushnumber(luaVM, ++uiIndex); + lua_pushresource(luaVM, *iter); + lua_settable(luaVM, -3); + } + return 1; +} + int CLuaResourceDefs::GetResourceState(lua_State* luaVM) { // string getResourceState ( resource theResource ) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaResourceDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaResourceDefs.h index 38d3bc8ac6..975eb47f7e 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaResourceDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaResourceDefs.h @@ -26,6 +26,7 @@ class CLuaResourceDefs : public CLuaDefs LUA_DECLARE(GetResourceGUIElement); LUA_DECLARE(GetResourceDynamicElementRoot); LUA_DECLARE(GetResourceExportedFunctions); + LUA_DECLARE(GetResources); LUA_DECLARE(GetResourceState); LUA_DECLARE(LoadString); LUA_DECLARE(Load);