当前位置: 首页>>代码示例>>C++>>正文


C++ VariableList::AddVar方法代码示例

本文整理汇总了C++中VariableList::AddVar方法的典型用法代码示例。如果您正苦于以下问题:C++ VariableList::AddVar方法的具体用法?C++ VariableList::AddVar怎么用?C++ VariableList::AddVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VariableList的用法示例。


在下文中一共展示了VariableList::AddVar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Execute

//执行
void COpScript::Execute(CMoveShape* pShape)
{
#ifdef _RUNSTACKINFO1_
    CMessage::AsyWriteFile(GetGame()->GetStatckFileName(), "COpScript::Execute() begin");
#endif
    //  [5/4/2009 chenxianj]
    //CScript *pTempScript =  PopFreeScript("COpScript::Execute");
    //if (pTempScript)
    //{
    //	pTempScript->SetVariableList(m_pParam->pVariableList);
    //	pTempScript->SetUsedItemID(m_pParam->GoodsGuid);
    //	pTempScript->SetSrcShapeEx(m_pParam->pUser);
    //	//  [5/4/2009 chenxianj]
    //	itExpress it = m_Expressions.begin();
    //	for(;it != m_Expressions.end();it++)
    //	{
    //		if(m_pParam->pUser)
    //			pTempScript->SetRegion(dynamic_cast<CRegion*>(m_pParam->pUser->GetFather()));
    //		else
    //			pTempScript->SetRegion(NULL);


    //		(*it)->Execute(pTempScript,pShape);

    //	}
    //	//  [5/4/2009 chenxianj]
    //	PushFreeScript(pTempScript);
    //}
    Script::RunEnv env( m_pParam->pUser, pShape, static_cast<CRegion*>( m_pParam->pUser->GetFather() ),
                        m_pParam->pVariableList );
    VariableList *varList = m_pParam->pVariableList;
    if( !varList->AddVar( "$ParamA", (double)(DWORD)m_pParam->pUser ) )
    {
        varList->SetVarValue( "$ParamA", (double)(DWORD) m_pParam->pUser );
    }
    if( !varList->AddVar( "$ParamB", (double)(DWORD)pShape ) )
    {
        varList->SetVarValue( "$ParamB", (double)(DWORD) pShape );
    }

    Script *script = GetInst( ScriptSys ).NewScript( env );
    for( itExpress it = m_Expressions.begin(); it != m_Expressions.end(); ++ it )
    {
        CExpressions *exp = *it;
        int ret = exp->Execute( script, pShape );
        if( !script->CanDelete( ret ) )
        {
            // yield script, cannot run.
            assert( "Yield script" && 0 );
        }
    }
    GetInst( ScriptSys ).DelScript( script );

#ifdef _RUNSTACKINFO1_
    CMessage::AsyWriteFile(GetGame()->GetStatckFileName(), "COpScript::Execute() end");
#endif
}
开发者ID:,项目名称:,代码行数:58,代码来源:

示例2: AddVar

	///
	/// 添加一个脚本变量到指定变量列表里
	///
	/// ret = AddVar( operType, "$varName", initVal, count =1 )
	/// @param operType: VT_SCRIPT, VT_SRCSHAPE, VT_DESTSHAPE
	/// @param varName 变量名
	/// @param initVal 初始值
	/// @param count [可选]数组长度,非数组为1
	///
	static int AddVar( lua_State *L )
	{
		Script *script = GetInst( ScriptSys ).GetScript( L );
		long operType = (long) tolua_tonumber( L, 1, 0 );
		VariableList *varList = ( script != NULL ? script->GetVarList( operType ) : NULL );
		bool ret = false;
		if( operType == Script::VT_GLOBAL )
		{
			// not support global variable list
			varList = NULL;
		}
		if( varList != NULL )
		{
			ret = true;
			long count = (long) tolua_tonumber( L, 4, 1 );
			const char *varName = TOLUA_TOSTRING( varName, L, 2, "" );
			long varType = VarList::VarType( varName );
			if( varType == VariableList::VAR_NUM )
			{
				VariableList::Number val = (VariableList::Number) tolua_tonumber( L, 3, 0 );
				varList->AddVar( varName, val, count );
			}
			else if( varType == VariableList::VAR_STRING )
			{
				const char *val = TOLUA_TOSTRING( val, L, 3, "" ); 
				varList->AddVar( varName, tString( val ), count );
			}
			else if( varType == VariableList::VAR_GUID )
			{
				const CGUID *val = TOLUA_TOGUID( val, L, 3, &NULL_GUID );
                varList->AddVar( varName, *val, count );
			}
			else
			{
				// argument error
				ret = false;
			}
		}
		else
		{
			// pop the arguments.
			int top = lua_gettop( L );
			lua_settop( L, top - 3 );
		}

		lua_pushboolean( L, ret ? 1 : 0 );
		return 1;
	}
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:57,代码来源:VarListFuncs.cpp


注:本文中的VariableList::AddVar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。