本文整理汇总了C++中CScriptArgReader::NextIsString方法的典型用法代码示例。如果您正苦于以下问题:C++ CScriptArgReader::NextIsString方法的具体用法?C++ CScriptArgReader::NextIsString怎么用?C++ CScriptArgReader::NextIsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CScriptArgReader
的用法示例。
在下文中一共展示了CScriptArgReader::NextIsString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fileWrite
int CLuaFileDefs::fileWrite ( lua_State* luaVM )
{
// int fileWrite ( file theFile, string string1 [, string string2, string string3 ...])
CScriptFile* pFile;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pFile );
// Ensure we have atleast one string
if ( !argStream.NextIsString () )
argStream.SetTypeError ( "string" );
if ( !argStream.HasErrors () )
{
long lBytesWritten = 0; // Total bytes written
// While we're not out of string arguments
// (we will always have at least one string because we validated it above)
while ( argStream.NextIsString () )
{
// Grab argument and length
SString strData;
argStream.ReadString ( strData );
unsigned long ulDataLen = strData.length ();
// Write the data
long lArgBytesWritten = pFile->Write ( ulDataLen, strData );
// Did the file mysteriously disappear?
if ( lArgBytesWritten == -1 )
{
m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 );
lua_pushnil ( luaVM );
return 1;
}
// Add the number of bytes written to our counter
lBytesWritten += lArgBytesWritten;
}
#ifdef MTA_CLIENT
// Inform file verifier
if ( lBytesWritten != 0 )
g_pClientGame->GetResourceManager ()->OnFileModifedByScript ( pFile->GetAbsPath (), "fileWrite" );
#endif
// Return the number of bytes we wrote
lua_pushnumber ( luaVM, lBytesWritten );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
// Error
lua_pushnil ( luaVM );
return 1;
}
示例2: textItemSetPriority
int CLuaTextDefs::textItemSetPriority ( lua_State* luaVM )
{
CTextItem * pTextItem;
int iPriority;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pTextItem );
if ( argStream.NextIsString( ) )
{
SString strPriority;
argStream.ReadString ( strPriority );
if ( strPriority == "high" ) iPriority = PRIORITY_HIGH;
else if ( strPriority == "medium" ) iPriority = PRIORITY_MEDIUM;
else iPriority = PRIORITY_LOW;
}
else
{
argStream.ReadNumber(iPriority);
}
if ( !argStream.HasErrors ( ) )
{
pTextItem->SetPriority ( (eTextPriority)iPriority );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例3: SetDevelopmentMode
int CLuaFunctionDefs::SetDevelopmentMode ( lua_State* luaVM )
{
// bool setDevelopmentMode ( bool enable )
// bool setDevelopmentMode ( string command )
bool bEnable; SString strCommand;
CScriptArgReader argStream ( luaVM );
if ( argStream.NextIsString () )
{
argStream.ReadString ( strCommand );
//g_pClientGame->SetDevSetting ( strCommand );
lua_pushboolean ( luaVM, true );
return 1;
}
argStream.ReadBool ( bEnable );
if ( !argStream.HasErrors () )
{
g_pClientGame->SetDevelopmentMode ( bEnable );
lua_pushboolean ( luaVM, true );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例4: fileWrite
int CLuaFileDefs::fileWrite ( lua_State* luaVM )
{
// int fileWrite ( file theFile, string string1 [, string string2, string string3 ...])
CScriptFile* pFile;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pFile );
if ( !argStream.NextIsString () )
argStream.SetTypeError ( "string" );
if ( !argStream.HasErrors () )
{
// While we're not out of string arguments
long lBytesWritten = 0;
long lArgBytesWritten = 0;
do
{
// Grab argument and length
SString strData;
argStream.ReadString ( strData );
unsigned long ulDataLen = strData.length ();
// Write it and add the bytes written to our total bytes written
lArgBytesWritten = pFile->Write ( ulDataLen, strData );
if ( lArgBytesWritten == -1 )
{
m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 );
lua_pushnil ( luaVM );
return 1;
}
lBytesWritten += lArgBytesWritten;
}
while ( argStream.NextIsString () );
// Return the number of bytes we wrote
lua_pushnumber ( luaVM, lBytesWritten );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
// Error
lua_pushnil ( luaVM );
return 1;
}
示例5: MixedReadGuiFontString
//
// GuiFont/string
//
void MixedReadGuiFontString ( CScriptArgReader& argStream, SString& strOutFontName, const char* szDefaultFontName, CClientGuiFont*& poutGuiFontElement )
{
poutGuiFontElement = NULL;
if ( argStream.NextIsString () || argStream.NextIsNone () )
argStream.ReadString ( strOutFontName, szDefaultFontName );
else
argStream.ReadUserData ( poutGuiFontElement );
}
示例6: AddBan
int CLuaBanDefs::AddBan ( lua_State* luaVM )
{
// ban addBan ( [ string IP, string Username, string Serial, player responsibleElement, string reason, int seconds = 0 ] )
SString strIP = "";
SString strUsername = "";
SString strSerial = "";
SString strResponsible = "Console";
CPlayer * pResponsible = NULL;
SString strReason = "";
time_t tUnban;
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strIP, "" );
argStream.ReadString ( strUsername, "" );
argStream.ReadString ( strSerial, "" );
if ( argStream.NextIsUserData () )
{
CElement* pResponsibleElement;
argStream.ReadUserData ( pResponsibleElement );
if ( ( pResponsible = dynamic_cast <CPlayer*> ( pResponsibleElement ) ) )
strResponsible = pResponsible->GetNick ();
}
else
argStream.ReadString ( strResponsible, "Console" );
argStream.ReadString ( strReason, "" );
if ( argStream.NextIsString () )
{
SString strTime;
argStream.ReadString ( strTime );
tUnban = atoi ( strTime );
}
else
if ( argStream.NextIsNumber () )
argStream.ReadNumber ( tUnban );
else
tUnban = 0;
if ( tUnban > 0 )
tUnban += time ( NULL );
if ( !argStream.HasErrors () )
{
CBan* pBan = NULL;
if ( ( pBan = CStaticFunctionDefinitions::AddBan ( strIP, strUsername, strSerial, pResponsible, strResponsible, strReason, tUnban ) ) )
{
lua_pushban ( luaVM, pBan );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例7: MixedReadResourceString
//
// Read next as resource or resource name. Result output as string
//
void MixedReadResourceString ( CScriptArgReader& argStream, SString& strOutResourceName )
{
if ( !argStream.NextIsString () )
{
CResource* pResource;
argStream.ReadUserData ( pResource );
if ( pResource )
strOutResourceName = pResource->GetName ();
}
else
argStream.ReadString ( strOutResourceName );
}
示例8: UnbindKey
int CLuaFunctionDefs::UnbindKey ( lua_State* luaVM )
{
SString strKey = "", strHitState = "";
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strKey );
if ( !argStream.HasErrors ( ) )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
if ( argStream.NextIsString ( 1 ) ) // Check if has command
{
// bool unbindKey ( string key, string keyState, string command )
SString strResource = pLuaMain->GetResource()->GetName();
SString strCommand = "";
argStream.ReadString ( strHitState );
argStream.ReadString ( strCommand );
if ( !argStream.HasErrors ( ) )
{
if ( CStaticFunctionDefinitions::UnbindKey ( strKey, strHitState, strCommand, strResource ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else
{
// bool unbindKey ( string key, [ string keyState, function handler ] )
CLuaFunctionRef iLuaFunction;
argStream.ReadString ( strHitState, "" );
argStream.ReadFunction ( iLuaFunction, LUA_REFNIL );
argStream.ReadFunctionComplete ();
if ( !argStream.HasErrors ( ) )
{
const char* szHitState = strHitState == "" ? NULL : strHitState.c_str();
if ( CStaticFunctionDefinitions::UnbindKey ( strKey, pLuaMain, szHitState, iLuaFunction ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
}
}
if ( argStream.HasErrors ( ) )
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例9: fileWrite
int CLuaFileDefs::fileWrite ( lua_State* luaVM )
{
// string fileWrite ( file, string [, string2, string3, ...] )
// Grab the file pointer
CScriptFile* pFile = NULL;
SString strMessage = "";
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pFile );
argStream.ReadString ( strMessage );
if ( !argStream.HasErrors ( ) )
{
if ( pFile )
{
// While we're not out of string arguments
long lBytesWritten = 0;
long lArgBytesWritten = 0;
do
{
unsigned long ulDataLen = strMessage.length ( );
// Write it and add the bytes written to our total bytes written
lArgBytesWritten = pFile->Write ( ulDataLen, strMessage.c_str ( ) );
if ( lArgBytesWritten == -1 )
{
m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 );
lua_pushnil ( luaVM );
return 1;
}
lBytesWritten += lArgBytesWritten;
if ( !argStream.NextIsString ( ) )
break;
argStream.ReadString ( strMessage );
}
while ( true );
// Return the number of bytes we wrote
lua_pushnumber ( luaVM, lBytesWritten );
return 1;
}
else
m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 );
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
// Error
lua_pushnil ( luaVM );
return 1;
}
示例10: BindKey
int CLuaFunctionDefs::BindKey ( lua_State* luaVM )
{
SString strKey = "", strHitState = "", strCommand = "", strArguments = "";
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strKey );
argStream.ReadString ( strHitState );
if ( !argStream.HasErrors ( ) )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
if ( argStream.NextIsString ( ) )
{
// bindKey ( string key, string keyState, string commandName, [ string arguments ] )
SString strResource = pLuaMain->GetResource()->GetName();
argStream.ReadString ( strCommand );
argStream.ReadString ( strArguments, "" );
if ( !argStream.HasErrors ( ) )
{
if ( CStaticFunctionDefinitions::BindKey ( strKey, strHitState, strCommand, strArguments, strResource ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else
{
// bindKey ( string key, string keyState, function handlerFunction, [ var arguments, ... ] )
CLuaFunctionRef iLuaFunction;
CLuaArguments Arguments;
argStream.ReadFunction ( iLuaFunction );
argStream.ReadLuaArguments ( Arguments );
argStream.ReadFunctionComplete ();
if ( !argStream.HasErrors ( ) )
{
if ( CStaticFunctionDefinitions::BindKey ( strKey, strHitState, pLuaMain, iLuaFunction, Arguments ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
}
}
if ( argStream.HasErrors ( ) )
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例11: fileWrite
int CLuaFileDefs::fileWrite ( lua_State* luaVM )
{
// string fileWrite ( file, string [, string2, string3, ...] )
CScriptFile* pFile;
SString strMessage;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pFile );
argStream.ReadString ( strMessage );
if ( !argStream.HasErrors ( ) )
{
// While we're not out of string arguments
long lBytesWritten = 0;
long lArgBytesWritten = 0;
do
{
unsigned long ulDataLen = strMessage.length ( );
// Write it and add the bytes written to our total bytes written
lArgBytesWritten = pFile->Write ( ulDataLen, strMessage.c_str ( ) );
if ( lArgBytesWritten == -1 )
{
m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 );
lua_pushnil ( luaVM );
return 1;
}
lBytesWritten += lArgBytesWritten;
if ( !argStream.NextIsString ( ) )
break;
argStream.ReadString ( strMessage );
}
while ( true );
// Inform file verifier
if ( lBytesWritten > 0 )
g_pClientGame->GetResourceManager()->OnFileModifedByScript( pFile->GetAbsPath(), "fileWrite" );
// Return the number of bytes we wrote
lua_pushnumber ( luaVM, lBytesWritten );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushnil ( luaVM );
return 1;
}
示例12: MixedReadDxFontString
//
// DxFont/string
//
void MixedReadDxFontString(CScriptArgReader& argStream, eFontType& outFontType, eFontType defaultFontType, CClientDxFont*& poutDxFontElement)
{
outFontType = FONT_DEFAULT;
poutDxFontElement = NULL;
if (argStream.NextIsNone())
return;
else if (argStream.NextIsString())
{
SString strFontName;
argStream.ReadString(strFontName);
StringToEnum(strFontName, outFontType);
return;
}
else
argStream.ReadUserData(poutDxFontElement);
}
示例13: ReadPregFlags
//
// Read next as preg option flags
//
void ReadPregFlags( CScriptArgReader& argStream, pcrecpp::RE_Options& pOptions )
{
if ( argStream.NextIsNumber() )
{
uint uiFlags = 0;
argStream.ReadNumber ( uiFlags );
pOptions.set_caseless ( ( uiFlags & 1 ) != 0 );
pOptions.set_multiline ( ( uiFlags & 2 ) != 0 );
pOptions.set_dotall ( ( uiFlags & 4 ) != 0 );
pOptions.set_extended ( ( uiFlags & 8 ) != 0 );
pOptions.set_utf8 ( ( uiFlags & 16 ) != 0 );
}
else
if ( argStream.NextIsString() )
{
SString strFlags;
argStream.ReadString ( strFlags );
for( uint i = 0 ; i < strFlags.length() ; i++ )
{
switch ( strFlags[i] )
{
case 'i':
pOptions.set_caseless ( true );
break;
case 'm':
pOptions.set_multiline ( true );
break;
case 'd':
pOptions.set_dotall ( true );
break;
case 'e':
pOptions.set_extended ( true );
break;
case 'u':
pOptions.set_utf8 ( true );
break;
default:
argStream.SetCustomError( "Flags all wrong" );
return;
}
}
}
}
示例14: MixedReadMaterialString
//
// Material/string
//
void MixedReadMaterialString(CScriptArgReader& argStream, CClientMaterial*& pMaterialElement)
{
pMaterialElement = NULL;
if (!argStream.NextIsString())
argStream.ReadUserData(pMaterialElement);
else
{
SString strFilePath;
argStream.ReadString(strFilePath);
// If no element, auto find/create one
CLuaMain* pLuaMain = g_pClientGame->GetLuaManager()->GetVirtualMachine(argStream.m_luaVM);
CResource* pParentResource = pLuaMain ? pLuaMain->GetResource() : NULL;
if (pParentResource)
{
CResource* pFileResource = pParentResource;
SString strPath, strMetaPath;
if (CResourceManager::ParseResourcePathInput(strFilePath, pFileResource, &strPath, &strMetaPath))
{
SString strUniqueName = SString("%s*%s*%s", pParentResource->GetName(), pFileResource->GetName(), strMetaPath.c_str()).Replace("\\", "/");
pMaterialElement = g_pClientGame->GetManager()->GetRenderElementManager()->FindAutoTexture(strPath, strUniqueName);
if (pMaterialElement)
{
// Check if brand new
if (!pMaterialElement->GetParent())
// Make it a child of the resource's file root ** CHECK Should parent be pFileResource, and element added to pParentResource's
// ElementGroup? **
pMaterialElement->SetParent(pParentResource->GetResourceDynamicEntity());
}
else
argStream.SetCustomError(strFilePath, "Error loading image");
}
else
argStream.SetCustomError(strFilePath, "Bad file path");
}
}
}
示例15: FetchRemote
// 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;
}