本文整理汇总了C++中CScriptArgReader::NextIsNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ CScriptArgReader::NextIsNumber方法的具体用法?C++ CScriptArgReader::NextIsNumber怎么用?C++ CScriptArgReader::NextIsNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CScriptArgReader
的用法示例。
在下文中一共展示了CScriptArgReader::NextIsNumber方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetWeaponTarget
int CLuaFunctionDefs::SetWeaponTarget ( lua_State* luaVM )
{
CClientWeapon * pWeapon;
CClientEntity * pTarget;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pWeapon );
if ( argStream.NextIsUserData() )
{
int targetBone;
argStream.ReadUserData ( pTarget );
argStream.ReadNumber ( targetBone, 255 );
if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::SetWeaponTarget ( pWeapon, pTarget, targetBone ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else if ( argStream.NextIsNumber() || argStream.NextIsUserDataOfType < CLuaVector3D > () )
{
CVector vecTarget;
argStream.ReadVector3D ( vecTarget );
if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::SetWeaponTarget ( pWeapon, vecTarget ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else if ( argStream.NextIsNil() )
{
if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::ClearWeaponTarget ( pWeapon ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else
argStream.SetCustomError( "Expected element, number or nil at argument 2" );
if ( argStream.HasErrors () )
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例2: Split
int CLuaFunctionDefs::Split ( lua_State* luaVM )
{
SString strInput = "";
unsigned int uiDelimiter = 0;
SString strDelimiter;
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strInput );
if ( argStream.NextIsNumber () )
{
argStream.ReadNumber ( uiDelimiter );
wchar_t wUNICODE[2] = { uiDelimiter, '\0' };
strDelimiter = UTF16ToMbUTF8 ( wUNICODE );
}
else // It's already a string
argStream.ReadString ( strDelimiter );
if ( !argStream.HasErrors () )
{
// Copy the string
char* strText = new char[strInput.length () + 1];
strcpy ( strText, strInput );
unsigned int uiCount = 0;
char* szToken = strtok ( strText, strDelimiter );
// Create a new table
lua_newtable ( luaVM );
// Add our first token
lua_pushnumber ( luaVM, ++uiCount );
lua_pushstring ( luaVM, szToken );
lua_settable ( luaVM, -3 );
// strtok until we're out of tokens
while ( ( szToken = strtok ( NULL, strDelimiter ) ) )
{
// Add the token to the table
lua_pushnumber ( luaVM, ++uiCount );
lua_pushstring ( luaVM, szToken );
lua_settable ( luaVM, -3 );
}
// Delete the text
delete[] strText;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
return 1;
}
示例3: 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;
}
示例4: OOP_OutputChatBox
int CLuaFunctionDefs::OOP_OutputChatBox ( lua_State * luaVM )
{
// bool Player:outputChat ( string text [, int r=231, int g=217, int b=176, bool colorCoded=false ] )
CElement* pElement; SString strText; uchar ucRed = 231; uchar ucGreen = 217; uchar ucBlue = 176; bool bColorCoded;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pElement );
argStream.ReadString ( strText );
if ( argStream.NextIsNumber ( 0 ) && argStream.NextIsNumber ( 1 ) && argStream.NextIsNumber ( 2 ) )
{
argStream.ReadNumber ( ucRed );
argStream.ReadNumber ( ucGreen );
argStream.ReadNumber ( ucBlue );
}
else
argStream.Skip ( 3 );
argStream.ReadBool ( bColorCoded, false );
if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
CStaticFunctionDefinitions::OutputChatBox ( strText, pElement, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain );
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例5: argStream
int CLuaVector4Defs::Pow ( lua_State* luaVM )
{
CLuaVector4D* pVector1 = NULL;
CLuaVector4D* pVector2 = NULL;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pVector1 );
if ( argStream.NextIsNumber () )
{
float fValue = 0.0f;
argStream.ReadNumber ( fValue );
CVector4D vector ( *pVector1 );
vector.fX = pow ( vector.fX, fValue );
vector.fY = pow ( vector.fY, fValue );
vector.fZ = pow ( vector.fZ, fValue );
vector.fW = pow ( vector.fW, fValue );
lua_pushvector ( luaVM, vector );
return 1;
}
else
{
argStream.ReadUserData ( pVector2 );
if ( !argStream.HasErrors () )
{
CVector4D vector ( *pVector1 );
vector.fX = pow ( vector.fX, pVector2->fX );
vector.fY = pow ( vector.fY, pVector2->fY );
vector.fZ = pow ( vector.fZ, pVector2->fZ );
vector.fW = pow ( vector.fW, pVector2->fW );
lua_pushvector ( luaVM, vector );
return 1;
}
else
{
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
}
}
lua_pushboolean ( luaVM, false );
return 1;
}
示例6: 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;
}
}
}
}
示例7: CallRemote
// Call a function on a remote server
int CLuaFunctionDefs::CallRemote ( lua_State* luaVM )
{
CScriptArgReader argStream ( luaVM );
if ( !argStream.NextIsFunction ( 1 ) && !argStream.NextIsFunction ( 2 ) )
{
// Call type 1
// bool callRemote ( string host [, int connectionAttempts = 10, int connectTimeout = 10000 ], string resourceName, string functionName, callback callbackFunction, [ arguments... ] )
SString strHost; uint uiConnectionAttempts; uint uiConnectTimeoutMs; SString strResourceName; SString strFunctionName; CLuaFunctionRef iLuaFunction; CLuaArguments args;
argStream.ReadString ( strHost );
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.ReadString ( strResourceName );
argStream.ReadString ( strFunctionName );
argStream.ReadFunction ( iLuaFunction );
argStream.ReadLuaArguments ( args );
argStream.ReadFunctionComplete ();
if ( !argStream.HasErrors () )
{
CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( luaMain )
{
g_pGame->GetRemoteCalls ()->Call ( strHost, strResourceName, strFunctionName, &args, luaMain, iLuaFunction, uiConnectionAttempts, uiConnectTimeoutMs );
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else
{
// Call type 2
// bool callRemote ( string URL [, int connectionAttempts = 10, int connectTimeout = 10000 ], callback callbackFunction, [ arguments... ] )
SString strURL; uint uiConnectionAttempts; uint uiConnectTimeoutMs; CLuaFunctionRef iLuaFunction; CLuaArguments args;
argStream.ReadString ( strURL );
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.ReadLuaArguments ( args );
argStream.ReadFunctionComplete ();
if ( !argStream.HasErrors () )
{
CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( luaMain )
{
g_pGame->GetRemoteCalls ()->Call ( strURL, &args, luaMain, iLuaFunction, uiConnectionAttempts, uiConnectTimeoutMs );
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
if ( argStream.HasErrors () )
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例8: setTrafficLightState
int CLuaWorldDefs::setTrafficLightState ( lua_State* luaVM )
{
// bool setTrafficLightState ( int state )
// bool setTrafficLightState ( string state )
// bool setTrafficLightState ( string colorNS, string colorEW )
CScriptArgReader argStream ( luaVM );
// Determine which version to parse
if ( argStream.NextIsNumber () )
{
// bool setTrafficLightState ( int state )
int iState;
argStream.ReadNumber ( iState );
if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::SetTrafficLightState ( iState ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else
if ( !argStream.NextIsString ( 1 ) )
{
// bool setTrafficLightState ( string state )
TrafficLight::EState eState;
argStream.ReadEnumString ( eState );
if ( !argStream.HasErrors () )
{
if ( eState == TrafficLight::AUTO )
{
bool bOk = CStaticFunctionDefinitions::SetTrafficLightsLocked ( false ) &&
CStaticFunctionDefinitions::SetTrafficLightState ( 0 );
lua_pushboolean ( luaVM, bOk );
return 1;
}
else
{
bool bOk = CStaticFunctionDefinitions::SetTrafficLightsLocked ( true ) &&
CStaticFunctionDefinitions::SetTrafficLightState ( 9 );
lua_pushboolean ( luaVM, bOk );
return 1;
}
}
}
else
{
// bool setTrafficLightState ( string colorNS, string colorEW )
TrafficLight::EColor eColorNS;
TrafficLight::EColor eColorEW;
argStream.ReadEnumString ( eColorNS );
argStream.ReadEnumString ( eColorEW );
if ( !argStream.HasErrors () )
{
unsigned char ucState = SharedUtil::GetTrafficLightStateFromColors ( eColorNS, eColorEW );
// Change it.
bool bOk = CStaticFunctionDefinitions::SetTrafficLightsLocked ( true ) &&
CStaticFunctionDefinitions::SetTrafficLightState ( ucState );
lua_pushboolean ( luaVM, bOk );
return 1;
}
}
if ( argStream.HasErrors () )
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例9: GetTok
int CLuaFunctionDefs::GetTok ( lua_State* luaVM )
{
SString strInput = "";
unsigned int uiToken = 0;
unsigned int uiDelimiter = 0;
SString strDelimiter;
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strInput );
argStream.ReadNumber ( uiToken );
if ( argStream.NextIsNumber ( ) )
{
argStream.ReadNumber ( uiDelimiter );
wchar_t wUNICODE[2] = { uiDelimiter, '\0' };
strDelimiter = UTF16ToMbUTF8(wUNICODE);
}
else // It's already a string
argStream.ReadString ( strDelimiter );
if ( !argStream.HasErrors ( ) )
{
unsigned int uiCount = 0;
if ( uiToken > 0 && uiToken < 1024 )
{
unsigned int uiCount = 1;
char* szText = new char [ strInput.length ( ) + 1 ];
strcpy ( szText, strInput );
char* szToken = strtok ( szText, strDelimiter );
// We're looking for the first part?
if ( uiToken != 1 )
{
// strtok count number of times
do
{
uiCount++;
szToken = strtok ( NULL, strDelimiter );
}
while ( uiCount != uiToken );
}
// Found it?
if ( szToken )
{
// Return it
lua_pushstring ( luaVM, szToken );
delete [] szText;
return 1;
}
// Delete the text
delete [] szText;
}
else
m_pScriptDebugging->LogWarning ( luaVM, "Token parameter sent to split must be greater than 0 and smaller than 1024" );
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}