Added a global "g_Plugin" object to all Lua plugins.

This allows plugins to have an empty Initialize function and implementing all their initialization at global level, thus modularising everything.
master
madmaxoft 2013-09-18 22:31:44 +02:00
parent a2d5f86769
commit 47ef25ce77
1 changed files with 3 additions and 0 deletions

View File

@ -81,6 +81,9 @@ bool cPluginLua::Initialize(void)
lua_setglobal(m_LuaState, LUA_PLUGIN_INSTANCE_VAR_NAME);
lua_pushstring(m_LuaState, GetName().c_str());
lua_setglobal(m_LuaState, LUA_PLUGIN_NAME_VAR_NAME);
tolua_pushusertype(m_LuaState, this, "cPluginLua");
lua_setglobal(m_LuaState, "g_Plugin");
}
std::string PluginPath = FILE_IO_PREFIX + GetLocalDirectory() + "/";