Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/CResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class CResourceManager
CResource* GetResourceFromLuaState(struct lua_State* luaVM);
SString GetResourceName(struct lua_State* luaVM);

std::list<CResource*>::const_iterator IterBegin() { return m_resources.begin(); };
std::list<CResource*>::const_iterator IterEnd() { return m_resources.end(); };

bool RemoveResource(unsigned short usID);
void Remove(CResource* pResource);
bool Exists(CResource* pResource);
Expand Down
15 changes: 15 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaResourceDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void CLuaResourceDefs::LoadFunctions()
{"getResourceGUIElement", GetResourceGUIElement},
{"getResourceDynamicElementRoot", GetResourceDynamicElementRoot},
{"getResourceExportedFunctions", GetResourceExportedFunctions},
{"getResources", GetResources},
{"getResourceState", GetResourceState},
{"loadstring", LoadString},
{"load", Load},
Expand Down Expand Up @@ -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<CResource*>::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 )
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaResourceDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down