bool CLuaMgr::LoadLua( const char *LuaFile ) { if ( LuaFile == NULL || LuaFile[0] == '\0' ) return false; if ( Lua() == NULL ) return false; std::string file = path + LuaFile; int error = luaL_dofile( Lua(), file.c_str() ); if ( error != 0 ) { LOG_DEBUG( "Error[%d] in CLuaMgr::LoadLua: lua_dofile[%s] -> ErrorString[%s]", error, LuaFile, !lua_isnil( Lua(), -1 ) ? lua_tostring( Lua(), -1 ) : "" ); return false; } GC(); LOG_DEBUG( "LoadLua:%s", LuaFile ); return true; }
void CLuaMgr::AddGlobalVal( const char *key, const char *val ) { if ( Lua() == NULL || key == NULL || val == '\0' ) return; uint32 top = lua_gettop( Lua() ); lua_pushstring( Lua(), val ); lua_setglobal( Lua(), key ); lua_settop( Lua(), top ); }
META_FUNCTION( sn3_bf_write, GetNumBytesLeft ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) ); sn3_bf_write *buf = GET_META( 1, sn3_bf_write ); Lua()->PushLong( buf->GetNumBytesLeft() ); return 1; }
META_FUNCTION( sn3_bf_write, IsOverflowed ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) ); sn3_bf_write *buf = GET_META( 1, sn3_bf_write ); Lua()->Push( buf->IsOverflowed() ); return 1; }
META_FUNCTION( dataFragments_t, GetFileTransferID ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) ); dataFragments_t *fragments = GET_META( 1, dataFragments_t ); Lua()->PushLong( fragments->transferid ); return 1; }
META_FUNCTION( dataFragments_t, GetFileName ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) ); dataFragments_t *fragments = GET_META( 1, dataFragments_t ); Lua()->Push( (const char *)fragments->filename ); return 1; }
META_FUNCTION( dataFragments_t, GetNum ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) ); dataFragments_t *fragments = GET_META( 1, dataFragments_t ); Lua()->PushLong( fragments->num ); return 1; }
META_FUNCTION( dataFragments_t, GetCompressed ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) ); dataFragments_t *fragments = GET_META( 1, dataFragments_t ); Lua()->Push( fragments->compressed ); return 1; }
META_FUNCTION( dataFragments_t, GetActualSize ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) ); dataFragments_t *fragments = GET_META( 1, dataFragments_t ); Lua()->PushLong( fragments->actualsize ); return 1; }
META_FUNCTION( dataFragments_t, SetFileTransferID ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) ); Lua()->CheckType( 2, GLua::TYPE_NUMBER ); dataFragments_t *fragments = GET_META( 1, dataFragments_t ); fragments->transferid = Lua()->GetInteger( 2 ); return 0; }
META_FUNCTION( dataFragments_t, SetFileName ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) ); Lua()->CheckType( 2 , GLua::TYPE_STRING ); dataFragments_t *fragments = GET_META( 1, dataFragments_t ); strcpy_s( fragments->filename, MAX_PATH, Lua()->GetString( 2 ) ); return 0; }
META_FUNCTION( dataFragments_t, SetProgress ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) ); Lua()->CheckType( 2, GLua::TYPE_NUMBER ); dataFragments_t *fragments = GET_META( 1, dataFragments_t ); fragments->progress = Lua()->GetInteger( 2 ); return 0; }
META_FUNCTION( dataFragments_t, SetStream ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) ); Lua()->CheckType( 2 , GLua::TYPE_BOOL ); dataFragments_t *fragments = GET_META( 1, dataFragments_t ); fragments->stream = Lua()->GetBool( 2 ); return 0; }
META_FUNCTION( sn3_bf_write, WriteBitVec3Coord ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) ); Lua()->CheckType( 2, GLua::TYPE_VECTOR ); sn3_bf_write *buf = GET_META( 1, sn3_bf_write ); buf->WriteBitVec3Coord( *GET_META( 2, Vector ) ); return 0; }
META_FUNCTION( INetworkStringTableContainer, FindTable ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( INetworkStringTableContainer ) ); Lua()->CheckType( 2, GLua::TYPE_STRING ); INetworkStringTableContainer *pContainer = GET_META( 1, INetworkStringTableContainer ); PUSH_META( pContainer->FindTable( Lua()->GetString( 2 ) ), INetworkStringTable ); return 1; }
META_FUNCTION( sn3_bf_write, Seek ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) ); Lua()->CheckType( 2, GLua::TYPE_NUMBER ); sn3_bf_write *buf = GET_META( 1, sn3_bf_write ); buf->SeekToBit( Lua()->GetInteger( 2 ) ); return 0; }
META_FUNCTION( sn3_bf_write, WriteString ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) ); Lua()->CheckType( 2, GLua::TYPE_STRING ); sn3_bf_write *buf = GET_META( 1, sn3_bf_write ); buf->WriteString( Lua()->GetString( 2 ) ); return 0; }
META_FUNCTION( sn3_bf_write, WriteShort ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) ); Lua()->CheckType( 2, GLua::TYPE_NUMBER ); sn3_bf_write *buf = GET_META( 1, sn3_bf_write ); buf->WriteShort( Lua()->GetInteger( 2 ) & 0xFFFF ); return 0; }
META_FUNCTION( sn3_bf_write, WriteFloat ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) ); Lua()->CheckType( 2, GLua::TYPE_NUMBER ); sn3_bf_write *buf = GET_META( 1, sn3_bf_write ); buf->WriteFloat( Lua()->GetNumber( 2 ) ); return 0; }
META_FUNCTION( dataFragments_t, SetActualSize ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) ); Lua()->CheckType( 2, GLua::TYPE_NUMBER ); dataFragments_t *fragments = GET_META( 1, dataFragments_t ); fragments->actualsize = Lua()->GetInteger( 2 ); return 0; }
META_FUNCTION( sn3_bf_write, WriteUBitLong ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) ); Lua()->CheckType( 2, GLua::TYPE_NUMBER ); Lua()->CheckType( 3, GLua::TYPE_NUMBER ); sn3_bf_write *buf = GET_META( 1, sn3_bf_write ); buf->WriteUBitLong( Lua()->GetInteger( 2 ), Lua()->GetInteger( 3 ) ); return 0; }
META_FUNCTION( sn3_bf_write, WriteBytes ) { UsesLua(); Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) ); Lua()->CheckType( 2, GET_META_ID( UCHARPTR ) ); Lua()->CheckType( 3, GLua::TYPE_NUMBER ); sn3_bf_write *buf = GET_META( 1, sn3_bf_write ); Lua()->Push( buf->WriteBytes( GET_META( 2, UCHARPTR ), Lua()->GetInteger( 3 ) ) ); return 1; }
META_FUNCTION( INetworkStringTableContainer, GetTable ) { UsesLua(); //Lua()->SetGlobal( "META_ID" , (double)GET_META_ID( INetworkStringTableContainer ) ); Lua()->CheckType( 1, GET_META_ID( INetworkStringTableContainer ) ); Lua()->CheckType( 2, GLua::TYPE_NUMBER ); INetworkStringTableContainer *pContainer = GET_META( 1, INetworkStringTableContainer ); PUSH_META( pContainer->GetTable( Lua()->GetInteger( 2 ) ), INetworkStringTable ); return 1; }
int Start(lua_State *L) { CreateInterfaceFn interfaceFactory = Sys_GetFactory( ENGINE_LIB ); CreateInterfaceFn gameServerFactory = Sys_GetFactory( SERVER_LIB ); CreateInterfaceFn physicsFactory = Sys_GetFactory( VPHYSICS_LIB ); surfaceprop = (IPhysicsSurfaceProps*)physicsFactory(VPHYSICS_SURFACEPROPS_INTERFACE_VERSION, NULL); engine = (IVEngineServer*)interfaceFactory(INTERFACEVERSION_VENGINESERVER, NULL); ILuaInterface *gLua = Lua(); ILuaObject *vmeta = gLua->GetMetaTable("Vehicle", GLua::TYPE_ENTITY); vmeta->SetMember("GetOperatingParams", getoperatingparams); vmeta->SetMember("GetVehicleParams", getvehicleparams); vmeta->SetMember("SetVehicleParams", setvehicleparams); vmeta->SetMember("SetWheelMaterial", SetWheelMaterial); vmeta->SetMember("GetWheelMaterial", GetWheelMaterial); vmeta->UnReference(); gLua->SetGlobal("GetUcmdButtons", GetUcmdButtons); gLua->SetGlobal("SetUcmdButtons", SetUcmdButtons); return 0; }
int Open(lua_State *L) { ml_Lua = Lua(); OldSpew = GetSpewOutputFunc(); SpewOutputFunc(NewSpew); ml_Lua->SetGlobal("SPEW_MESSAGE", (float)SPEW_MESSAGE); ml_Lua->SetGlobal("SPEW_WARNING", (float)SPEW_WARNING); ml_Lua->SetGlobal("SPEW_ASSERT", (float)SPEW_ASSERT); ml_Lua->SetGlobal("SPEW_ERROR", (float)SPEW_ERROR); ml_Lua->SetGlobal("SPEW_LOG", (float)SPEW_LOG); ml_Lua->SetGlobal("SPEW_TYPE_COUNT", (float)SPEW_TYPE_COUNT); ml_Lua->SetGlobal("SPEW_DEBUGGER", (float)SPEW_DEBUGGER); ml_Lua->SetGlobal("SPEW_CONTINUE", (float)SPEW_CONTINUE); ml_Lua->SetGlobal("SPEW_TYPE_COUNT", (float)SPEW_TYPE_COUNT); ml_Lua->SetGlobal("SPEW_ABORT", (float)SPEW_ABORT); ml_Lua->NewGlobalTable("simplespew"); ILuaObject* simplespew = ml_Lua->GetGlobal("simplespew"); simplespew->SetMember("Remove", RemoveSpew); simplespew->UnReference(); AddRemoveHook("ShutDown"); AddRemoveHook("OnConfirmQuit"); //Extras return 0; }
void lua_uv_stream_write_resume(uv_write_t * req, int status) { dprintf("lua_uv_stream_write_resume\n"); lua_State * L = (lua_State *)req->data; callback_resume_after(L); lua_pushinteger(L, status); Lua(L).resume(1); }
int Init( lua_State *L ) { if (FAILED(::CoInitialize(NULL))) return 1; HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&Voice); if( !SUCCEEDED( hr ) ) return 1; Voice->GetVolume(&DefaultVolume); Voice->GetRate(&DefaultRate); Voice->GetVoice(&DefaultVoice); ILuaInterface* gLua = Lua(); ILuaObject* tts = gLua->GetNewTable(); tts->SetMember( "Say", Say ); tts->SetMember( "IsSpeaking", IsSpeaking ); tts->SetMember( "QueueSize", QueueSize ); tts->SetMember( "Pause", Pause ); tts->SetMember( "Resume", Resume ); gLua->SetGlobal( "tts", tts ); tts->UnReference(); return 0; }
void CLuaMgr::GC(void) { if ( Lua() != NULL ) { lua_gc( plua, LUA_GCCOLLECT, 0 ); } }
bool cPrefabPiecePool::LoadFromCubesetFile(const AString & a_FileName, bool a_LogWarnings) { // Load the file in the Lua interpreter: cLuaState Lua(Printf("LoadablePiecePool %s", a_FileName.c_str())); Lua.Create(); if (!Lua.LoadFile(a_FileName, a_LogWarnings)) { // Reason for failure has already been logged in LoadFile() return false; } // Check the version: int Version = 0; if (!Lua.GetNamedGlobal("Cubeset.Metadata.CubesetFormatVersion", Version)) { CONDWARNING(a_LogWarnings, "Cannot load cubeset %s, it doesn't contain version information.", a_FileName.c_str()); return false; } // Load the data, using the correct version loader: if (Version == 1) { return LoadFromCubesetFileVer1(a_FileName, Lua, a_LogWarnings); } // Unknown version: CONDWARNING(a_LogWarnings, "Cannot load cubeset %s, version (%d) not supported.", a_FileName.c_str(), Version); return false; }
void CFurryFinder::Steam_OnGSGroupStatus( GSClientGroupStatus_t *pParam ) { Lua()->Push( Lua()->GetGlobal( "hook" )->GetMember( "Call" ) ); Lua()->Push( "GSGroupStatus" ); Lua()->PushNil(); // gamemode Lua()->Push( pParam->m_SteamIDUser.Render() ); Lua()->Push( pParam->m_SteamIDGroup.Render() ); Lua()->Push( pParam->m_bMember ); Lua()->Push( pParam->m_bOfficer ); Lua()->Call( 6, 0 ); }