本文整理汇总了C++中CScriptArgReader::NextCouldBeNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ CScriptArgReader::NextCouldBeNumber方法的具体用法?C++ CScriptArgReader::NextCouldBeNumber怎么用?C++ CScriptArgReader::NextCouldBeNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CScriptArgReader
的用法示例。
在下文中一共展示了CScriptArgReader::NextCouldBeNumber方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateColPolygon
int CLuaColShapeDefs::CreateColPolygon ( lua_State* luaVM )
{
CVector2D vecPosition;
CScriptArgReader argStream ( luaVM );
argStream.ReadVector2D ( vecPosition );
if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
CResource* pResource = pLuaMain->GetResource ();
if ( pResource )
{
// Create it and return it
CClientColPolygon* pShape = CStaticFunctionDefinitions::CreateColPolygon ( *pResource, vecPosition );
if ( pShape )
{
// Get the points
while ( argStream.NextCouldBeNumber () && argStream.NextCouldBeNumber ( 1 ) )
{
argStream.ReadVector2D ( vecPosition );
pShape->AddPoint ( vecPosition );
}
CElementGroup * pGroup = pResource->GetElementGroup ();
if ( pGroup )
{
pGroup->Add ( pShape );
}
lua_pushelement ( luaVM, pShape );
return 1;
}
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例2: SetPedAnimation
int CLuaPedDefs::SetPedAnimation ( lua_State* luaVM )
{
// bool setPedAnimation ( ped thePed [, string block=nil, string anim=nil, int time=-1, bool loop=true, bool updatePosition=true, bool interruptable=true, bool freezeLastFrame = true] )
CElement * pPed;
SString strBlockName, strAnimName;
int iTime;
bool bLoop, bUpdatePosition, bInterruptable, bFreezeLastFrame;
bool bDummy;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pPed );
if ( argStream.NextIsBool () )
argStream.ReadBool ( bDummy ); // Wiki used setPedAnimation(source,false) as an example
else
if ( argStream.NextIsNil () )
argStream.m_iIndex++; // Wiki docs said blockName could be nil
else
argStream.ReadString ( strBlockName, "" );
argStream.ReadString ( strAnimName, "" );
if ( argStream.NextCouldBeNumber () ) // Freeroam skips the time arg sometimes
argStream.ReadNumber ( iTime, -1 );
else
iTime = -1;
argStream.ReadBool ( bLoop, true );
argStream.ReadBool ( bUpdatePosition, true );
argStream.ReadBool ( bInterruptable, true );
argStream.ReadBool ( bFreezeLastFrame, true );
if ( !argStream.HasErrors () )
{
const char *szBlock, *szAnim;
szBlock = strBlockName.empty () ? NULL : strBlockName.c_str ();
szAnim = strAnimName.empty () ? NULL : strAnimName.c_str ();
if ( CStaticFunctionDefinitions::SetPedAnimation ( pPed, szBlock, szAnim, iTime, bLoop, bUpdatePosition, bInterruptable, bFreezeLastFrame ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例3: PlayMissionAudio
int CLuaFunctionDefs::PlayMissionAudio ( lua_State* luaVM )
{
CElement* pElement;
CVector vecPosition;
unsigned short usSlot;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pElement );
argStream.ReadNumber ( usSlot );
if ( argStream.NextCouldBeNumber () )
{
argStream.ReadVector3D ( vecPosition );
if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::PlayMissionAudio ( pElement, &vecPosition, usSlot ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
}
else if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::PlayMissionAudio ( pElement, NULL, usSlot ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例4: GetCTime
int CLuaFunctionDefs::GetCTime ( lua_State* luaVM )
{
// table getRealTime( [int seconds = current], bool localTime = true )
time_t timer;
time ( &timer );
bool bLocalTime = true;
CScriptArgReader argStream ( luaVM );
if ( argStream.NextCouldBeNumber () )
{
argStream.ReadNumber ( timer );
if ( timer < 0 )
{
argStream.SetCustomError ( "seconds cannot be negative" );
}
}
if ( argStream.NextIsBool () )
argStream.ReadBool ( bLocalTime );
tm * time;
if ( bLocalTime )
time = localtime ( &timer );
else
time = gmtime ( &timer );
if ( time == NULL )
argStream.SetCustomError ( "seconds is out of range" );
if ( argStream.HasErrors () )
{
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
CLuaArguments ret;
ret.PushString ( "second" );
ret.PushNumber ( time->tm_sec );
ret.PushString ( "minute" );
ret.PushNumber ( time->tm_min );
ret.PushString ( "hour" );
ret.PushNumber ( time->tm_hour );
ret.PushString ( "monthday" );
ret.PushNumber ( time->tm_mday );
ret.PushString ( "month" );
ret.PushNumber ( time->tm_mon );
ret.PushString ( "year" );
ret.PushNumber ( time->tm_year );
ret.PushString ( "weekday" );
ret.PushNumber ( time->tm_wday );
ret.PushString ( "yearday" );
ret.PushNumber ( time->tm_yday );
ret.PushString ( "isdst" );
ret.PushNumber ( time->tm_isdst );
ret.PushString ( "timestamp" );
ret.PushNumber ( (double) timer );
ret.PushAsTable ( luaVM );
return 1;
}