本文整理汇总了C++中CScriptArgReader::NextIsNil方法的典型用法代码示例。如果您正苦于以下问题:C++ CScriptArgReader::NextIsNil方法的具体用法?C++ CScriptArgReader::NextIsNil怎么用?C++ CScriptArgReader::NextIsNil使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CScriptArgReader
的用法示例。
在下文中一共展示了CScriptArgReader::NextIsNil方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toJSON
int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
{
// Got a string argument?
CScriptArgReader argStream ( luaVM );
if ( !argStream.NextIsNil ( ) )
{
// Read the argument
CLuaArguments JSON;
JSON.ReadArgument ( luaVM, 1 );
// Convert it to a JSON string
std::string strJSON;
if ( JSON.WriteToJSONString ( strJSON ) )
{
// Return the JSON string
lua_pushstring ( luaVM, strJSON.c_str () );
return 1;
}
}
else
m_pScriptDebugging->LogBadType ( luaVM );
// Failed
lua_pushnil ( luaVM );
return 1;
}
示例2: FocusBrowser
int CLuaFunctionDefs::FocusBrowser ( lua_State* luaVM )
{
// focusBrowser ( browser webBrowser )
CClientWebBrowser* pWebBrowser;
CScriptArgReader argStream ( luaVM );
if ( argStream.NextIsNil () || argStream.NextIsNone () )
{
g_pCore->GetWebCore ()->SetFocusedWebView ( NULL );
lua_pushboolean ( luaVM, true );
return 1;
}
argStream.ReadUserData ( pWebBrowser );
if ( !argStream.HasErrors () )
{
pWebBrowser->Focus ();
lua_pushboolean ( luaVM, true );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例3: SetWeaponOwner
int CLuaFunctionDefs::SetWeaponOwner ( lua_State* luaVM )
{
CClientWeapon * pWeapon;
CClientPlayer * pPlayer;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pWeapon );
if ( argStream.NextIsUserData() )
{
argStream.ReadUserData ( pPlayer );
if ( !argStream.HasErrors () )
{
pWeapon->SetOwner( pPlayer );
lua_pushboolean ( luaVM, true );
return 1;
}
}
else if ( argStream.NextIsNil() )
{
if ( !argStream.HasErrors () )
{
pWeapon->SetOwner( NULL );
lua_pushboolean ( luaVM, true );
return 1;
}
}
if ( argStream.HasErrors() )
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushnil ( luaVM );
return 1;
}
示例4: GetAccount
int CLuaFunctionDefs::GetAccount ( lua_State* luaVM )
{
// account getAccount ( string username, [ string password ] )
SString strName; SString strPassword;
bool bUsePassword = false;
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strName );
if ( !argStream.NextIsNil () && !argStream.NextIsNone () )
{
argStream.ReadString ( strPassword );
bUsePassword = true;
}
if ( !argStream.HasErrors () )
{
CAccount* pAccount = CStaticFunctionDefinitions::GetAccount ( strName, bUsePassword ? strPassword.c_str () : NULL );
if ( pAccount )
{
lua_pushaccount ( luaVM, pAccount );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例5: toJSON
int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
{
// Got a string argument?
CScriptArgReader argStream ( luaVM );
if ( !argStream.NextIsNil () )
{
bool bCompact = false;
// Read the argument
CLuaArguments JSON;
JSON.ReadArgument ( luaVM, 1 );
argStream.Skip ( 1 );
argStream.ReadBool ( bCompact, false );
if ( !argStream.HasErrors () )
{
// Convert it to a JSON string
std::string strJSON;
if ( JSON.WriteToJSONString ( strJSON, false, bCompact ) )
{
// Return the JSON string
lua_pushstring ( luaVM, strJSON.c_str () );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
}
else
m_pScriptDebugging->LogBadType ( luaVM );
// Failed
lua_pushnil ( luaVM );
return 1;
}
示例6: 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() )
{
CVector vecTarget;
argStream.ReadNumber( vecTarget.fX );
argStream.ReadNumber( vecTarget.fY );
argStream.ReadNumber( vecTarget.fZ );
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;
}
示例7: Reference
int CLuaFunctionDefs::Reference ( lua_State* luaVM )
{
CScriptArgReader argStream ( luaVM );
if ( !argStream.NextIsNil () && !argStream.NextIsNone () )
{
int iPointer = lua_ref ( luaVM, 1 );
lua_pushnumber ( luaVM, iPointer );
return 1;
}
lua_pushboolean ( luaVM, false );
return 1;
}
示例8: 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;
}
示例9: toJSON
int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
{
// Got a string argument?
CScriptArgReader argStream ( luaVM );
if ( !argStream.NextIsNil () )
{
int jsonFlags = 0;
// Read the argument
CLuaArguments JSON;
JSON.ReadArgument ( luaVM, 1 );
argStream.Skip ( 1 );
bool bCompact;
argStream.ReadBool ( bCompact, false );
jsonFlags |= bCompact ? JSON_C_TO_STRING_PLAIN : JSON_C_TO_STRING_SPACED;
eJSONPrettyType jsonPrettyType;
argStream.ReadEnumString ( jsonPrettyType, JSONPRETTY_NONE );
if ( jsonPrettyType != JSONPRETTY_NONE )
jsonFlags |= jsonPrettyType;
if ( !argStream.HasErrors () )
{
// Convert it to a JSON string
std::string strJSON;
if ( JSON.WriteToJSONString ( strJSON, false, jsonFlags ) )
{
// Return the JSON string
lua_pushstring ( luaVM, strJSON.c_str () );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
}
else
m_pScriptDebugging->LogBadType ( luaVM );
// Failed
lua_pushnil ( luaVM );
return 1;
}
示例10: SetBrowserAjaxHandler
int CLuaFunctionDefs::SetBrowserAjaxHandler ( lua_State* luaVM )
{
// bool setBrowserAjaxHandler ( browser browser, string URL[, function callback] )
CClientWebBrowser* pWebBrowser; SString strURL; CLuaFunctionRef callbackFunction;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pWebBrowser );
argStream.ReadString ( strURL );
if ( argStream.NextIsNil () || argStream.NextIsNone () )
{
if ( !argStream.HasErrors () )
{
lua_pushboolean ( luaVM, pWebBrowser->RemoveAjaxHandler ( strURL ) );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
}
else
{
argStream.ReadFunction ( callbackFunction );
argStream.ReadFunctionComplete ();
if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain && VERIFY_FUNCTION ( callbackFunction ) )
{
CResource* pResource = pLuaMain->GetResource ();
CResourceManager * pResourceManager = m_pResourceManager;
auto netId = pResource->GetNetID ();
bool bResult = pWebBrowser->AddAjaxHandler ( strURL,
[=] ( std::vector<SString>& vecGet, std::vector<SString>& vecPost ) -> const SString
{
// Make sure the resource is still running
if ( !pResourceManager->Exists ( pResource ) || pResource->GetNetID() != netId )
{
return "";
}
// Make sure the function is valid
if ( VERIFY_FUNCTION ( callbackFunction ) )
{
CLuaArguments arguments;
CLuaArguments getArguments;
CLuaArguments postArguments;
for ( auto&& param : vecGet )
getArguments.PushString ( param );
for ( auto&& param : vecPost )
postArguments.PushString ( param );
arguments.PushTable ( &getArguments );
arguments.PushTable ( &postArguments );
CLuaArguments result;
arguments.Call ( pLuaMain, callbackFunction, &result );
if ( result.Count () == 0 )
return "";
CLuaArgument* returnedValue = *result.IterBegin ();
if ( returnedValue->GetType () == LUA_TSTRING )
return returnedValue->GetString ();
else
return "";
}
else
return "";
} );
lua_pushboolean ( luaVM, bResult );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
}
lua_pushboolean ( luaVM, false );
return 1;
}