本文整理汇总了C++中CScriptArgReader::NextIsBool方法的典型用法代码示例。如果您正苦于以下问题:C++ CScriptArgReader::NextIsBool方法的具体用法?C++ CScriptArgReader::NextIsBool怎么用?C++ CScriptArgReader::NextIsBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CScriptArgReader
的用法示例。
在下文中一共展示了CScriptArgReader::NextIsBool方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetSoundEffectEnabled
int CLuaFunctionDefs::SetSoundEffectEnabled ( lua_State* luaVM )
{
CClientPlayer* pPlayer = NULL;
CClientSound* pSound = NULL;
SString strEffectName = "";
CScriptArgReader argStream ( luaVM );
if ( argStream.NextIsUserDataOfType < CClientSound > ( ) )
{
argStream.ReadUserData ( pSound );
}
else if ( argStream.NextIsUserDataOfType < CClientPlayer > ( ) )
{
argStream.ReadUserData ( pPlayer );
}
else
{
m_pScriptDebugging->LogBadPointer ( luaVM, "sound/player", 1 );
lua_pushboolean ( luaVM, false );
return false;
}
argStream.ReadString ( strEffectName );
if ( !argStream.HasErrors() )
{
if ( pSound )
{
bool bEnable = false;
if ( argStream.NextIsBool ( ) )
{
argStream.ReadBool ( bEnable );
}
if ( CStaticFunctionDefinitions::SetSoundEffectEnabled ( *pSound, strEffectName, bEnable ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
else if ( pPlayer )
{
bool bEnable = false;
if ( argStream.NextIsBool ( ) )
{
argStream.ReadBool ( bEnable );
}
if ( CStaticFunctionDefinitions::SetSoundEffectEnabled ( *pPlayer, strEffectName, bEnable ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例2: EngineLoadTXD
int CLuaEngineDefs::EngineLoadTXD ( lua_State* luaVM )
{
SString strFile = "";
bool bFilteringEnabled = true;
CScriptArgReader argStream ( luaVM );
// Grab the TXD filename or data
argStream.ReadString ( strFile );
if ( argStream.NextIsBool() ) // Some scripts have a number here (in error)
argStream.ReadBool ( bFilteringEnabled, true );
if ( !argStream.HasErrors ( ) )
{
// Grab our virtual machine and grab our resource from that.
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
// Grab this resource
CResource* pResource = pLuaMain->GetResource ();
if ( pResource )
{
bool bIsRawData = CClientTXD::IsTXDData( strFile );
SString strPath;
// Is this a legal filepath?
if ( bIsRawData || CResourceManager::ParseResourcePathInput( strFile, pResource, &strPath ) )
{
// Grab the resource root entity
CClientEntity* pRoot = pResource->GetResourceTXDRoot ();
// Create a TXD element
CClientTXD* pTXD = new CClientTXD ( m_pManager, INVALID_ELEMENT_ID );
// Try to load the TXD file
if ( pTXD->LoadTXD ( bIsRawData ? strFile : strPath, bFilteringEnabled, bIsRawData ) )
{
// Success loading the file. Set parent to TXD root
pTXD->SetParent ( pRoot );
// Return the TXD
lua_pushelement ( luaVM, pTXD );
return 1;
}
else
{
// Delete it again
delete pTXD;
argStream.SetCustomError( bIsRawData ? "raw data" : strFile, "Error loading TXD" );
}
}
else
argStream.SetCustomError( bIsRawData ? "raw data" : strFile, "Bad file path" );
}
}
}
if ( argStream.HasErrors() )
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
// We failed
lua_pushboolean ( luaVM, false );
return 1;
}
示例3: SetWorldSoundEnabled
int CLuaFunctionDefs::SetWorldSoundEnabled ( lua_State* luaVM )
{
// setWorldSoundEnabled ( int group, [int index, ], bool enable )
int group; int index = -1; bool bEnabled;
CScriptArgReader argStream ( luaVM );
argStream.ReadNumber ( group );
if ( !argStream.NextIsBool () )
argStream.ReadNumber ( index );
argStream.ReadBool ( bEnabled );
if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::SetWorldSoundEnabled ( group, index, bEnabled ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例4: argStream
int CLuaFunctionDefs::PlaySound3D ( lua_State* luaVM )
{
SString strSound = "";
CVector vecPosition;
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strSound );
argStream.ReadNumber ( vecPosition.fX );
argStream.ReadNumber ( vecPosition.fY );
argStream.ReadNumber ( vecPosition.fZ );
if ( !argStream.HasErrors() )
{
CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( luaMain )
{
CResource* pResource = luaMain->GetResource();
if ( pResource )
{
SString strFilename;
bool bIsURL = false;
if ( CResourceManager::ParseResourcePathInput( strSound, pResource, strFilename ) )
strSound = strFilename;
else
bIsURL = true;
// ParseResourcePathInput changes pResource in some cases e.g. an invalid resource URL - crun playSound( ":myNotRunningResource/music/track.mp3" )
// Fixes #6507 - Caz
if ( pResource )
{
bool bLoop = false;
if ( argStream.NextIsBool ( ) )
{
argStream.ReadBool ( bLoop );
}
CClientSound* pSound = CStaticFunctionDefinitions::PlaySound3D ( pResource, strSound, bIsURL, vecPosition, bLoop );
if ( pSound )
{
// call onClientSoundStarted
CLuaArguments Arguments;
Arguments.PushString ( "play" ); // Reason
pSound->CallEvent ( "onClientSoundStarted", Arguments, false );
lua_pushelement ( luaVM, pSound );
return 1;
}
}
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例5: SetPlayerNametagColor
int CLuaPlayerDefs::SetPlayerNametagColor ( lua_State* luaVM )
{
CScriptArgReader argStream ( luaVM );
if ( !argStream.NextIsBool ( 1 ) )
{
// Call type 1
// bool setPlayerNametagColor ( player thePlayer, int r, int g, int b )
CClientEntity* pPlayer; int iR; int iG; int iB;
argStream.ReadUserData ( pPlayer );
argStream.ReadNumber ( iR );
argStream.ReadNumber ( iG );
argStream.ReadNumber ( iB );
if ( !argStream.HasErrors () )
{
if ( CStaticFunctionDefinitions::SetPlayerNametagColor ( *pPlayer, false, iR, iG, iB ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else
{
// Call type 2
// bool setPlayerNametagColor ( player thePlayer, false )
CClientEntity* pPlayer; bool bFalse;
argStream.ReadUserData ( pPlayer );
argStream.ReadBool ( bFalse );
if ( !argStream.HasErrors () )
{
if ( bFalse == false )
{
if ( CStaticFunctionDefinitions::SetPlayerNametagColor ( *pPlayer, true, 255, 255, 255 ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
}
if ( argStream.HasErrors () )
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例6: 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;
}
示例7: 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;
}