本文整理汇总了C++中CScriptArgReader::SetTypeError方法的典型用法代码示例。如果您正苦于以下问题:C++ CScriptArgReader::SetTypeError方法的具体用法?C++ CScriptArgReader::SetTypeError怎么用?C++ CScriptArgReader::SetTypeError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CScriptArgReader
的用法示例。
在下文中一共展示了CScriptArgReader::SetTypeError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: MixedReadResourceString
//
// Read next as resource or resource name. Result output as resource
//
void MixedReadResourceString ( CScriptArgReader& argStream, CResource*& pOutResource )
{
if ( !argStream.NextIsString () )
{
argStream.ReadUserData ( pOutResource );
}
else
{
SString strResourceName;
argStream.ReadString ( strResourceName );
pOutResource = g_pGame->GetResourceManager ()->GetResource ( strResourceName );
if ( !pOutResource )
argStream.SetTypeError ( "resource", argStream.m_iIndex - 1 );
}
}
示例3: 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;
}