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


C++ LuaObject::GetByName方法代码示例

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


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

示例1: getGlobalVars

LuaPlus::LuaObject ant::LuaStateManager::createPath( const std::string& path, bool ignoreLastElement /*= false*/ )
{
	StringVec splitPath;
	Split(path,splitPath, '.');
	if (ignoreLastElement)
	{
		splitPath.pop_back();
	}

	LuaPlus::LuaObject context = getGlobalVars();
	for (auto it = splitPath.begin() ; it != splitPath.end() ; it++)
	{
		// Is the context valid?
		if (context.IsNil())
		{
			GCC_ERROR("Something broke in CreatePath(); bailing out (element == " + (*it) + ")");
			return context;  // this will be nil
		}

		// grab whatever exists for this element
		const std::string& element = (*it);
		LuaPlus::LuaObject curr = context.GetByName(element.c_str());

		if (!curr.IsTable())
		{
			// if the element is not a table and not nil, we clobber it
			if (!curr.IsNil())
			{
				GCC_WARNING("Overwriting element '" + element + "' in table");
				context.SetNil(element.c_str());
			}

			// element is either nil or was clobbered so add the new table
			context.CreateTable(element.c_str());
		}

		context = context.GetByName(element.c_str());
	}

	// We have created a complete path here
	return context;
}
开发者ID:Ostkaka,项目名称:ANT,代码行数:42,代码来源:LuaStateManager.cpp

示例2: throw

    // /////////////////////////////////////////////////////////////////
    //
    // /////////////////////////////////////////////////////////////////
    SliderControl::SliderControl(const LuaPlus::LuaObject &widgetScriptData, \
                                 boost::shared_ptr<ModelViewProjStackManager> mvpStackManPtr, \
                                 const boost::shared_ptr<GLSLShader> shaderFlatObj, \
                                 const boost::shared_ptr<GLSLShader> shaderTexObj, \
                                 boost::shared_ptr<FTFont> fontPtr, \
                                 const ScreenElementId id) throw(GameException &)\
:
    ControlWidget(widgetScriptData, mvpStackManPtr, shaderFlatObj, shaderTexObj, fontPtr, id)
    , m_sliderPos(0.5f)
    , m_sliderButPtr()
    , m_sliderLineBatch()
    , m_sliding(false)
    , m_eventTypeId(0)
    , m_lineColor(0.0f, 0.0f, 0.0f, 1.0f)
    {
        SetLuaSliderPosition(widgetScriptData.GetByName("SliderPosition"));
        SetLuaEventId(widgetScriptData.GetByName("EventTypeId"));
        std::string buttonTableName;
        LuaPlus::LuaObject tableName = widgetScriptData.GetByName("ButtonTableId");
        if(tableName.IsString()) {
            LuaPlus::LuaObject buttonData = widgetScriptData.GetByName(tableName.GetString());
            if(buttonData.IsTable()) {
                m_sliderButPtr.reset(GCC_NEW ButtonControl(buttonData, mvpStackManPtr, shaderFlatObj, shaderTexObj, fontPtr, 0));
                m_sliderButPtr->VSetPosition(CalculateButtonPositionFromSlider());
                m_sliderButPtr->VSetText("");
                m_sliderButPtr->VSetWidth(GetProjectedButtonWidth());
                m_sliderButPtr->VSetHeight(GetProjectedButtonHeight());
                m_sliderButPtr->VSetVisible(VIsVisible());
                m_sliderButPtr->VSetEnabled(VIsEnabled());
                m_sliderButPtr->SetSendEvent(false);
            } else {
                GF_LOG_TRACE_ERR("SliderControl::SliderControl()", "Creation of scripted slider button failed.  Creating default button");
                CreateDefaultButton(VGetColor(), mvpStackManPtr, fontPtr, shaderFlatObj, shaderTexObj, VIsVisible(), VIsEnabled());
            }
        } else {
            GF_LOG_TRACE_ERR("SliderControl::SliderControl()", "Missing slider button information from script so creating default button");
            CreateDefaultButton(VGetColor(), mvpStackManPtr, fontPtr, shaderFlatObj, shaderTexObj, VIsVisible(), VIsEnabled());
        }

        RebuildSliderLine();
    }
开发者ID:pjohalloran,项目名称:gameframework,代码行数:44,代码来源:SliderControl.cpp

示例3: throw

    // /////////////////////////////////////////////////////////////////
    //
    // /////////////////////////////////////////////////////////////////
    ListButtonControl::ListButtonControl(const LuaPlus::LuaObject &widgetScriptData, \
                                         boost::shared_ptr<ModelViewProjStackManager> mvpStackManPtr, \
                                         const boost::shared_ptr<GLSLShader> shaderFlatObj, \
                                         const boost::shared_ptr<GLSLShader> shaderTexObj, \
                                         boost::shared_ptr<FTFont> fontPtr, \
                                         const ScreenElementId id) throw(GameException &)\
:
    ButtonControl(widgetScriptData, mvpStackManPtr, shaderFlatObj, shaderTexObj, fontPtr, id)
    , m_list()
    , m_curr()
    {
        SetLuaTextList(widgetScriptData.GetByName("TextTable"));
        if(!m_list.empty()) {
            m_curr = m_list.begin();
        }
        Init();
    }
开发者ID:pjohalloran,项目名称:gameframework,代码行数:20,代码来源:ListButtonControl.cpp

示例4: Register

//---------------------------------------------------------------------------------------------------------------------
// This function registers all the ScriptExports functions with the scripting system.  It is called in 
// Application::Init().
//---------------------------------------------------------------------------------------------------------------------
void ScriptExports::Register(void)
{
	LuaPlus::LuaObject globals = LuaStateManager::Get()->GetGlobalVars();

	// init	
	InternalScriptExports::Init();

	// resource loading
	globals.RegisterDirect("LoadAndExecuteScriptResource", &InternalScriptExports::LoadAndExecuteScriptResource);

	// actors
	globals.RegisterDirect("CreateActor", &InternalScriptExports::CreateActor);

	// event system
	globals.RegisterDirect("RegisterEventListener", &InternalScriptExports::RegisterEventListener);
	globals.RegisterDirect("RemoveEventListener", &InternalScriptExports::RemoveEventListener);
	globals.RegisterDirect("QueueEvent", &InternalScriptExports::QueueEvent);
	globals.RegisterDirect("TriggerEvent", &InternalScriptExports::TriggerEvent);
	
	// process system
	globals.RegisterDirect("AttachProcess", &InternalScriptExports::AttachScriptProcess);

    // math
    LuaPlus::LuaObject mathTable = globals.GetByName("GccMath");
    GCC_ASSERT(mathTable.IsTable());
    mathTable.RegisterDirect("GetYRotationFromVector", &InternalScriptExports::GetYRotationFromVector);
    mathTable.RegisterDirect("WrapPi", &InternalScriptExports::WrapPi);
    mathTable.RegisterDirect("GetVectorFromRotation", &InternalScriptExports::GetVectorFromRotation);
	
	// misc
	globals.RegisterDirect("Log", &InternalScriptExports::LuaLog);
    globals.RegisterDirect("GetTickCount", &InternalScriptExports::GetTickCount);

	// Physics
	globals.RegisterDirect("ApplyForce", &InternalScriptExports::ApplyForce);
	globals.RegisterDirect("ApplyTorque", &InternalScriptExports::ApplyTorque);
}
开发者ID:wsantas,项目名称:gamecode4,代码行数:41,代码来源:ScriptExports.cpp

示例5: Register

//=============================================================
//	C Functions for registering C++ functions to Lua script
//=============================================================
void LuaScriptExports::Register()
{
	LuaPlus::LuaObject globals = LuaStateManager::Get()->GetGlobalVars();

	// init
	LuaInternalScriptExports::Init();

	// resource loading
	globals.RegisterDirect("LoadAndExecuteScriptResource", &LuaInternalScriptExports::LoadAndExecuteScriptResource);

	// gameobjects
	globals.RegisterDirect("CreateObject", &LuaInternalScriptExports::CreateGameObject);

	// events
	globals.RegisterDirect("RegisterEventListener", &LuaInternalScriptExports::RegisterEventListener);
	globals.RegisterDirect("RemoveEventListener", &LuaInternalScriptExports::RemoveEventListener);
	globals.RegisterDirect("QueueEvent", &LuaInternalScriptExports::QueueEvent);
	globals.RegisterDirect("TriggerEvent", &LuaInternalScriptExports::TriggerEvent);

	// processes
	globals.RegisterDirect("AttachProcess", &LuaInternalScriptExports::AttachScriptProcess);

	// math (these are registered to GccMath, not global
	LuaPlus::LuaObject mathTable = globals.GetByName("GccMath");
	CB_ASSERT(mathTable.IsTable());
	mathTable.RegisterDirect("GetYRotationFromVector", &LuaInternalScriptExports::GetYRotationFromVector);
	mathTable.RegisterDirect("WrapPi", &LuaInternalScriptExports::WrapPi);
	mathTable.RegisterDirect("GetVectorFromRotation", &LuaInternalScriptExports::GetVectorFromRotation);

	// misc
	globals.RegisterDirect("Log", &LuaInternalScriptExports::LuaLog);
	globals.RegisterDirect("GetTickCount", &LuaInternalScriptExports::GetTickCount);

	// physics
	globals.RegisterDirect("ApplyForce", &LuaInternalScriptExports::ApplyForce);
	globals.RegisterDirect("ApplyTorque", &LuaInternalScriptExports::ApplyTorque);
}
开发者ID:deanmarsinelli,项目名称:City-Protectors,代码行数:40,代码来源:LuaScriptExports.cpp


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