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


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

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


在下文中一共展示了VariableList::SetVarValue方法的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: SetVar

	///
	/// 设置指定列表里某个变量的值
	///
	/// ret = SetVar( operType, "$varName", val, pos )
	/// @param operType:VT_SCRIPT, VT_SRCSHAPE, VT_DESTSHAPE, VT_GLOBAL
	/// @param varName 变量名
	/// @param val 变量值
	/// @param pos [可选]数组索引
	///
	static int SetVar( 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( varList != NULL )
		{
			ret = true;
			long index = (long) tolua_tonumber( L, 4, 0 );
			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->SetVarValue( varName, val, index );
				if( operType == Script::VT_GLOBAL )
				{
					ScriptUtils::UpdateValToWS( varName, val, index );
				}
			}
			else if( varType == VariableList::VAR_STRING )
			{
				const char *val = TOLUA_TOSTRING( val, L, 3, "" ); 
				varList->SetVarValue( varName, tString( val ), index );
				if( operType == Script::VT_GLOBAL )
				{
					ScriptUtils::UpdateValToWS( varName, tString( val ), index );
				}
			}
			else if( varType == VariableList::VAR_GUID )
			{
				const CGUID *val = TOLUA_TOGUID( val, L, 3, &NULL_GUID ); 
				varList->SetVarValue( varName, *val, index );
				if( operType == Script::VT_GLOBAL )
				{
					ScriptUtils::UpdateValToWS( varName, *val, index );
				}
			}
			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,代码行数:64,代码来源:VarListFuncs.cpp


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