|
|
@ -77,7 +77,7 @@ CComLuaModule::CComLuaModule(CDynamicMapClient* client, lua_State *luaState /*=
|
|
|
|
#ifdef LUA_NEVRAX_VERSION
|
|
|
|
#ifdef LUA_NEVRAX_VERSION
|
|
|
|
_LuaState = lua_open(NULL, NULL);
|
|
|
|
_LuaState = lua_open(NULL, NULL);
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
_LuaState = lua_open();
|
|
|
|
_LuaState = luaL_newstate();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
_LuaOwnerShip = false;
|
|
|
|
_LuaOwnerShip = false;
|
|
|
|
luaopen_base(_LuaState);
|
|
|
|
luaopen_base(_LuaState);
|
|
|
@ -105,7 +105,7 @@ CComLuaModule::CComLuaModule(CDynamicMapClient* client, lua_State *luaState /*=
|
|
|
|
void CComLuaModule::initLuaLib()
|
|
|
|
void CComLuaModule::initLuaLib()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//H_AUTO(R2_CComLuaModule_initLuaLib)
|
|
|
|
//H_AUTO(R2_CComLuaModule_initLuaLib)
|
|
|
|
const luaL_reg methods[] =
|
|
|
|
const luaL_Reg methods[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{"updateScenario", CComLuaModule::luaUpdateScenario},
|
|
|
|
{"updateScenario", CComLuaModule::luaUpdateScenario},
|
|
|
|
{"requestUpdateRtScenario", CComLuaModule::luaRequestUpdateRtScenario},
|
|
|
|
{"requestUpdateRtScenario", CComLuaModule::luaRequestUpdateRtScenario},
|
|
|
@ -237,7 +237,12 @@ void CComLuaModule::initLuaLib()
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
int initialStackSize = lua_gettop(_LuaState);
|
|
|
|
int initialStackSize = lua_gettop(_LuaState);
|
|
|
|
|
|
|
|
#if LUA_VERSION_NUM >= 502
|
|
|
|
|
|
|
|
luaL_newlib(_LuaState, methods);
|
|
|
|
|
|
|
|
lua_setglobal(_LuaState, R2_LUA_PATH);
|
|
|
|
|
|
|
|
#else
|
|
|
|
luaL_openlib(_LuaState, R2_LUA_PATH, methods, 0);
|
|
|
|
luaL_openlib(_LuaState, R2_LUA_PATH, methods, 0);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
lua_settop(_LuaState, initialStackSize);
|
|
|
|
lua_settop(_LuaState, initialStackSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1046,7 +1051,11 @@ void CComLuaModule::setObjectToLua(lua_State* state, CObject* object)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int initialStackSize = lua_gettop(state);
|
|
|
|
int initialStackSize = lua_gettop(state);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if LUA_VERSION_NUM >= 502
|
|
|
|
|
|
|
|
lua_pushglobaltable(state); // _G
|
|
|
|
|
|
|
|
#else
|
|
|
|
lua_pushvalue(state, LUA_GLOBALSINDEX); // _G
|
|
|
|
lua_pushvalue(state, LUA_GLOBALSINDEX); // _G
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
lua_pushstring(state, "r2"); // _G, "r2"
|
|
|
|
lua_pushstring(state, "r2"); // _G, "r2"
|
|
|
|
lua_gettable(state, -2); // G, r2
|
|
|
|
lua_gettable(state, -2); // G, r2
|
|
|
@ -1106,6 +1115,8 @@ void CComLuaModule::setObjectToLua(lua_State* state, CObject* object)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
// okay!
|
|
|
|
if (0)
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
@ -1128,6 +1139,7 @@ void CComLuaModule::setObjectToLua(lua_State* state, CObject* object)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1147,8 +1159,11 @@ CObject* CComLuaModule::getObjectFromLua(lua_State* state, sint idx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (lua_getmetatable(state, -1))
|
|
|
|
if (lua_getmetatable(state, -1))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#if LUA_VERSION_NUM >= 502
|
|
|
|
|
|
|
|
lua_pushglobaltable(state); // obj, mt, _G
|
|
|
|
|
|
|
|
#else
|
|
|
|
lua_pushvalue(state, LUA_GLOBALSINDEX); // obj, mt, _G
|
|
|
|
lua_pushvalue(state, LUA_GLOBALSINDEX); // obj, mt, _G
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
lua_pushstring(state, "r2"); // obj, mt, _G, "r2"
|
|
|
|
lua_pushstring(state, "r2"); // obj, mt, _G, "r2"
|
|
|
|
|
|
|
|
|
|
|
|