int CLuaFunctionDefs::SetMapName ( lua_State* luaVM ) { // bool setMapName ( string mapName ) SString strMapName; CScriptArgReader argStream ( luaVM ); argStream.ReadIfNextIsString ( strMapName, "" ); // Default to empty for backward compat with previous implementation if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::SetMapName ( strMapName ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
// Call a function on a remote server int CLuaFunctionDefs::FetchRemote ( lua_State* luaVM ) { // bool fetchRemote ( string URL [, string queueName ][, int connectionAttempts = 10, int connectTimeout = 10000 ], callback callbackFunction, [ string postData, bool bPostBinary, arguments... ] ) CScriptArgReader argStream ( luaVM ); SString strURL; SString strQueueName; CLuaFunctionRef iLuaFunction; SString strPostData; bool bPostBinary; CLuaArguments args; uint uiConnectionAttempts; uint uiConnectTimeoutMs; argStream.ReadString ( strURL ); if ( argStream.NextIsString () ) MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_QUEUE_NAME, "'queue name' is being used" ); argStream.ReadIfNextIsString ( strQueueName, CALL_REMOTE_DEFAULT_QUEUE_NAME ); if ( argStream.NextIsNumber () ) MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECTION_ATTEMPTS, "'connection attempts' is being used" ); argStream.ReadIfNextIsNumber ( uiConnectionAttempts, 10 ); if ( argStream.NextIsNumber () ) MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECT_TIMEOUT, "'connect timeout' is being used" ); argStream.ReadIfNextIsNumber ( uiConnectTimeoutMs, 10000 ); argStream.ReadFunction ( iLuaFunction ); argStream.ReadString ( strPostData, "" ); argStream.ReadBool ( bPostBinary, false ); argStream.ReadLuaArguments ( args ); argStream.ReadFunctionComplete (); if ( !argStream.HasErrors () ) { CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( luaMain ) { g_pGame->GetRemoteCalls ()->Call ( strURL, &args, strPostData, bPostBinary, luaMain, iLuaFunction, strQueueName, uiConnectionAttempts, uiConnectTimeoutMs ); lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }