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


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

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


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

示例1: ScriptEventDelegate

void ScriptEventListener::ScriptEventDelegate(IEventDataPtr pEvent)
{
    GCC_ASSERT(m_scriptCallbackFunction.IsFunction());  // this should never happen since it's validated before even creating this object

    // call the Lua function
	shared_ptr<ScriptEvent> pScriptEvent = static_pointer_cast<ScriptEvent>(pEvent);
	LuaPlus::LuaFunction<void> Callback = m_scriptCallbackFunction;
	Callback(pScriptEvent->GetEventData());
}
开发者ID:wsantas,项目名称:gamecode4,代码行数:9,代码来源:ScriptExports.cpp

示例2: ScriptOnUpdate

    void ScriptOnUpdate(ActorId id, const util::Vec3& position, int levelSize)
    {
        LuaPlus::LuaObject o = chimera::g_pApp->GetScript()->GetState()->GetGlobal("OnUpdate");
        if(!o.IsNil() && o.IsFunction())
        {
            LuaPlus::LuaFunction<void> function = chimera::g_pApp->GetScript()->GetState()->GetGlobal("OnUpdate");

            function(chimera::script::GetIntegerObject(id), chimera::script::GetVec3Object(position), chimera::script::GetIntegerObject(levelSize));
        }
    }
开发者ID:moresascha,项目名称:Chimera,代码行数:10,代码来源:AIView.cpp

示例3: IdentifyLuaObjectType

 // /////////////////////////////////////////////////////////////////
 //
 // /////////////////////////////////////////////////////////////////
 void LuaStateManager::IdentifyLuaObjectType(LuaPlus::LuaObject &objToTest)
 {
     assert(!objToTest.IsNil() && "Nil!");
     assert(!objToTest.IsBoolean() && "Boolean!");
     assert(!objToTest.IsCFunction() && "C-Function!");
     assert(!objToTest.IsFunction() && "Function!");
     assert(!objToTest.IsInteger() && "Integer!");
     assert(!objToTest.IsLightUserData() && "Light User Data!");
     assert(!objToTest.IsNone() && "None!");
     assert(!objToTest.IsNumber() && "Number!");
     assert(!objToTest.IsString() && "String!");
     assert(!objToTest.IsTable() && "Table!");
     assert(!objToTest.IsUserData() && "User Data!");
     assert(!objToTest.IsWString() && "Wide String!");
     assert(0 && "UNKNOWN!");
 }
开发者ID:pjohalloran,项目名称:gameframework,代码行数:19,代码来源:LuaStateManager.cpp

示例4: ScriptEventListener

ant::Ulong ant::InternalLuaScriptExports::registerEventListener( EventType eventType, LuaPlus::LuaObject callbackFunction )
{
	GCC_ASSERT(s_ScriptEventListenerMgrInstance);

	if (callbackFunction.IsFunction())
	{
		// Create the C++ listener proxy and set it to listen for the event
		ScriptEventListener* pListener = GCC_NEW ScriptEventListener(eventType, callbackFunction);
		s_ScriptEventListenerMgrInstance->addListener(pListener);
		IEventManager::instance()->addListener(pListener->getDelegate(), eventType);

		// Convert the pointer to an unsigned log to use as a handle
		ant::Ulong handle = reinterpret_cast<ant::Ulong>(pListener);
		return handle;
	}

	GCC_ERROR("Attempting to register script event listener with invalid callback function");
	return 0;
}
开发者ID:Ostkaka,项目名称:ANT,代码行数:19,代码来源:LuaScriptExports.cpp

示例5: RegisterEventListener

//---------------------------------------------------------------------------------------------------------------------
// Instantiates a C++ ScriptListener object, inserts it into the manager, and returns a handle to it.  The script 
// should maintain the handle if it needs to remove the listener at some point.  Otherwise, the listener will be 
// destroyed when the program exits.
//---------------------------------------------------------------------------------------------------------------------
unsigned long InternalScriptExports::RegisterEventListener(EventType eventType, LuaPlus::LuaObject callbackFunction)
{
	GCC_ASSERT(s_pScriptEventListenerMgr);

	if (callbackFunction.IsFunction())
	{
		// create the C++ listener proxy and set it to listen for the event
		ScriptEventListener* pListener = GCC_NEW ScriptEventListener(eventType, callbackFunction);
		s_pScriptEventListenerMgr->AddListener(pListener);
		IEventManager::Get()->VAddListener(pListener->GetDelegate(), eventType);
		
		// convert the pointer to an unsigned long to use as the handle
		unsigned long handle = reinterpret_cast<unsigned long>(pListener);
		return handle;
	}

	GCC_ERROR("Attempting to register script event listener with invalid callback function");
	return 0;
}
开发者ID:wsantas,项目名称:gamecode4,代码行数:24,代码来源:ScriptExports.cpp

示例6: RegisterEventListener

// add a lua listener callback for an event type. this will still be inserted into the C++ event manager
// which will fire events that are forward to the lua callback
unsigned long LuaInternalScriptExports::RegisterEventListener(EventType eventType, LuaPlus::LuaObject callbackFunction)
{
	CB_ASSERT(s_pScriptEventListenerMgr);
	// make sure the lua object is a function
	if (callbackFunction.IsFunction())
	{
		// create C++ proxy listener to listen for the event. this will forward the events to the lua callback
		LuaScriptEventListener* pListener = CB_NEW LuaScriptEventListener(eventType, callbackFunction);
		// add the listener to the lua listener manager
		s_pScriptEventListenerMgr->AddListener(pListener);
		// add its delegate listener function to the C++ event manager. this is where the events actually fire from
		IEventManager::Get()->AddListener(pListener->GetDelegate(), eventType);

		// conver the pointer to an unsigned long and use that as a handle
		unsigned long handle = reinterpret_cast<unsigned long>(pListener);
		return handle;
	}

	CB_ERROR("Invalid callback. Make sure the lua listener is a function");
	return 0;
}
开发者ID:deanmarsinelli,项目名称:City-Protectors,代码行数:23,代码来源:LuaScriptExports.cpp

示例7: PrintTable

void LuaManager::PrintTable(LuaPlus::LuaObject table, bool recursive)
{
	if(table.IsNil())
	{
		if(!recursive)
			GLIB_LOG("LuaManager", "null table");
		return;
	}

	if(!recursive)
		GLIB_LOG("LuaManager", "PrintTable()");

	cout << (!recursive ? "--\n" : "{ ");

	bool noMembers = true;
	for(LuaPlus::LuaTableIterator iter(table); iter; iter.Next())
	{
		noMembers = false;

		LuaPlus::LuaObject key = iter.GetKey();
		LuaPlus::LuaObject value = iter.GetValue();

		cout << key.ToString() << ": ";
		if(value.IsFunction())
			cout << "function" << "\n";
		else if(value.IsTable())
			PrintTable(value, true);
		else if(value.IsLightUserData())
			cout << "light user data" << "\n";
		else
			cout << value.ToString() << ", ";
	}

	cout << (!recursive ? "\n--" : "}");
	cout << endl;
}
开发者ID:simplerr,项目名称:Devbox,代码行数:36,代码来源:LuaManager.cpp


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