///////////// Copyright © 2009 LodleNet. All rights reserved. ///////////// // // Project : Server // File : ge_luamanager.cpp // Description : // Updated for LUA 5.2 // // Created On: 3/5/2009 4:58:54 PM // Created By: // Created By: //////////////////////////////////////////////////////////////////////////// #include "cbase.h" #include "luamanager.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" void RegisterLUAFuncs(lua_State *L); void RegisterLUAGlobals(lua_State *L); CLUAManager gLuaMng; CLUAManager* GetLuaManager() { return &gLuaMng; } void RegPublicFunctions(lua_State *L) { //add global lua functions here //RegisterLUAFuncs(L); } void RegPublicGlobals(lua_State *L) { //add global lua defines here //RegisterLUAGlobals(L); } //////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////// LuaHandle* g_NLuaHandle = NULL; LuaHandle* GetNLuaHandle() { return g_NLuaHandle; } LuaHandle::LuaHandle() { pL = NULL; } LuaHandle::~LuaHandle() { GetLuaManager()->DeRegisterLuaHandle(this); pL = NULL; } void LuaHandle::InitDll() { //Create an instance; Load the core libs. pL = luaL_newstate(); luaopen_base(pL); /* opens the basic library */ luaopen_table(pL); /* opens the table library */ luaopen_string(pL); /* opens the string lib. */ luaopen_math(pL); /* opens the math lib. */ #ifdef _DEBUG luaopen_debug(pL); #endif RegFunctions(); RegGlobals(); RegPublicFunctions(pL); RegPublicGlobals(pL); Init(); } void LuaHandle::ShutdownDll() { Shutdown(); lua_close(pL); } void LuaHandle::Register() { GetLuaManager()->RegisterLuaHandle(this); } //////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////// CLUAManager::CLUAManager() { m_bInit = false; } CLUAManager::~CLUAManager() { } void CLUAManager::InitDll() { // Register our LUA Functions and Globals so we can call them // from .lua scripts for (size_t x = 0; xInitDll(); } m_bInit = true; //ZMSLuaGamePlay *p = GetGP(); //p->m_bLuaLoaded = true; } void CLUAManager::ShutdownDll() { for (size_t x = 0; xShutdown(); } m_vHandles.clear(); } void CLUAManager::DeRegisterLuaHandle(LuaHandle* handle) { if (!handle) return; for (size_t x = 0; xInitDll(); } void RegisterLUAFuncs(lua_State *L) { } void RegisterLUAGlobals(lua_State *L) { }