1
0

Added cPluginManager:GetCurrentPlugin() to Lua API.

This commit is contained in:
madmaxoft 2013-12-05 22:03:07 +01:00
parent 1373539bce
commit 1205c540ee

View File

@ -990,7 +990,6 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
const cPluginManager::PluginMap & AllPlugins = self->GetAllPlugins();
lua_newtable(tolua_S);
//lua_createtable(tolua_S, AllPlugins.size(), 0);
int newTable = lua_gettop(tolua_S);
int index = 1;
cPluginManager::PluginMap::const_iterator iter = AllPlugins.begin();
@ -1006,7 +1005,6 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
{
tolua_pushboolean(tolua_S, 0);
}
//lua_rawseti(tolua_S, newTable, index);
lua_rawset(tolua_S, -3);
++iter;
++index;
@ -1018,6 +1016,22 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
static int tolua_cPluginManager_GetCurrentPlugin(lua_State * S)
{
cPluginLua * Plugin = GetLuaPlugin(S);
if (Plugin == NULL)
{
// An error message has already been printed in GetLuaPlugin()
return 0;
}
tolua_pushusertype(S, Plugin, "cPluginLua");
return 1;
}
static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager, cLuaState & S, int a_ParamIdx)
{
// Helper function for cPluginmanager:AddHook() binding
@ -2231,6 +2245,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "ForEachCommand", tolua_cPluginManager_ForEachCommand);
tolua_function(tolua_S, "ForEachConsoleCommand", tolua_cPluginManager_ForEachConsoleCommand);
tolua_function(tolua_S, "GetAllPlugins", tolua_cPluginManager_GetAllPlugins);
tolua_function(tolua_S, "GetCurrentPlugin", tolua_cPluginManager_GetCurrentPlugin);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlayer");