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.
This commit is contained in:
parent
a2d5f86769
commit
47ef25ce77
@ -81,6 +81,9 @@ bool cPluginLua::Initialize(void)
|
|||||||
lua_setglobal(m_LuaState, LUA_PLUGIN_INSTANCE_VAR_NAME);
|
lua_setglobal(m_LuaState, LUA_PLUGIN_INSTANCE_VAR_NAME);
|
||||||
lua_pushstring(m_LuaState, GetName().c_str());
|
lua_pushstring(m_LuaState, GetName().c_str());
|
||||||
lua_setglobal(m_LuaState, LUA_PLUGIN_NAME_VAR_NAME);
|
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() + "/";
|
std::string PluginPath = FILE_IO_PREFIX + GetLocalDirectory() + "/";
|
||||||
|
Loading…
Reference in New Issue
Block a user