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


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

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


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

示例1: EventListenerDelegate

 void LuaEventListener::EventListenerDelegate(event::IEventPtr event)
 {
     LuaScriptEventTransformation* t = chimera::g_pApp->GetScriptEventManager()->GetTransformation(event->VGetEventType());
     if(t)
     {
         if(!m_function.IsFunction())
         {
             LOG_ERROR_NR((std::string(m_function.GetString()) + std::string(" is not a function")).c_str());
         }
         LuaPlus::LuaFunction<void> function(m_function);
         
         LuaPlus::LuaObject obj = t->VBuildForScript(event);
         if(obj.IsNil())
         {
             function();
         }
         else
         {
             function(obj);
         }
     }
     else
     {
         LOG_ERROR("no Transformation");
     }
 }
开发者ID:moresascha,项目名称:Chimera,代码行数:26,代码来源:ScriptEvent.cpp

示例2: UnregisterScriptFunctions

void LuaScriptComponent::UnregisterScriptFunctions()
{
	// nil out the meta table object in lua
	LuaPlus::LuaObject metaTableObj = LuaStateManager::Get()->GetGlobalVars().Lookup(LUA_METATABLE_NAME);
	if (!metaTableObj.IsNil())
		metaTableObj.AssignNil(LuaStateManager::Get()->GetLuaState());
}
开发者ID:deanmarsinelli,项目名称:City-Protectors,代码行数:7,代码来源:ScriptComponent.cpp

示例3: 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

示例4: 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

示例5: pProcess

void ant::InternalLuaScriptExports::attachScriptProcess( LuaPlus::LuaObject scriptProcess )
{
	LuaPlus::LuaObject temp = scriptProcess.Lookup("__object");
	if (!temp.IsNil())
	{
		IProcessStrongPtr pProcess(static_cast<IProcess*>(temp.GetLightUserData()));
		ProcessManagerSingleton::instance()->getProcessManager()->attachProcess(pProcess);
	}
	else
	{
		GCC_ERROR("Could not find __object in script proces");
	}
}
开发者ID:Ostkaka,项目名称:ANT,代码行数:13,代码来源:LuaScriptExports.cpp

示例6: AttachScriptProcess

void InternalScriptExports::AttachScriptProcess(LuaPlus::LuaObject scriptProcess)
{
	LuaPlus::LuaObject temp = scriptProcess.Lookup("__object");
	if (!temp.IsNil())
	{
		shared_ptr<Process> pProcess(static_cast<Process*>(temp.GetLightUserData()));
        g_pApp->m_pGame->AttachProcess(pProcess);
	}
	else
	{
		GCC_ERROR("Couldn't find __object in script process");
	}
}
开发者ID:wsantas,项目名称:gamecode4,代码行数:13,代码来源:ScriptExports.cpp

示例7: RegisterEventTypeWithScript

//---------------------------------------------------------------------------------------------------------------------
// This function is called to register an event type with the script to link them.  The simplest way to do this is 
// with the REGISTER_SCRIPT_EVENT() macro, which calls this function.
//---------------------------------------------------------------------------------------------------------------------
void ScriptEvent::RegisterEventTypeWithScript(const char* key, EventType type)
{
	// get or create the EventType table
	LuaPlus::LuaObject eventTypeTable = LuaStateManager::Get()->GetGlobalVars().GetByName("EventType");
	if (eventTypeTable.IsNil())
		eventTypeTable = LuaStateManager::Get()->GetGlobalVars().CreateTable("EventType");

	// error checking
	GCC_ASSERT(eventTypeTable.IsTable());
	GCC_ASSERT(eventTypeTable[key].IsNil());
	
	// add the entry
	eventTypeTable.SetNumber(key, (double)type);
}
开发者ID:Rocket-Buddha,项目名称:GameCode4,代码行数:18,代码来源:ScriptEvent.cpp

示例8: CreateScriptObject

void BaseScriptComponent::CreateScriptObject(void)
{
    LuaStateManager* pStateMgr = LuaStateManager::Get();
    AC_ASSERT(pStateMgr);
	AC_ASSERT(!m_scriptObject.IsNil());
	
	LuaPlus::LuaObject metaTableObj = pStateMgr->GetGlobalVars().Lookup(METATABLE_NAME);
	AC_ASSERT(!metaTableObj.IsNil());
	
	LuaPlus::LuaObject boxedPtr = pStateMgr->GetLuaState()->BoxPointer(this);
	boxedPtr.SetMetaTable(metaTableObj);
	m_scriptObject.SetLightUserData("__object", this);
	m_scriptObject.SetMetaTable(metaTableObj);
}
开发者ID:JDHDEV,项目名称:AlphaEngine,代码行数:14,代码来源:BaseScriptComponent.cpp

示例9: RegisterEventTransformer

        void LuaScriptEventManager::RegisterEventTransformer(LuaScriptEventTransformation transformer, EventType type, LPCSTR name)
        {
            LuaScript* luas = (LuaScript*)chimera::g_pApp->GetScript();
            LuaPlus::LuaObject table = luas->GetState()->GetGlobals().GetByName("EventType");

            if(table.IsNil())
            {
                table = luas->GetState()->GetGlobals().CreateTable("EventType");
            }

            table.SetNumber(name, type);

            m_transformMap[type] = transformer;
        }
开发者ID:moresascha,项目名称:Chimera,代码行数:14,代码来源:ScriptEvent.cpp

示例10: CreateScriptObject

void LuaScriptComponent::CreateScriptObject()
{
	LuaStateManager* pStateManager = LuaStateManager::Get();
	CB_ASSERT(pStateManager);
	CB_ASSERT(!m_ScriptObject.IsNil());

	LuaPlus::LuaObject metaTableObj = pStateManager->GetGlobalVars().Lookup(LUA_METATABLE_NAME);
	CB_ASSERT(!metaTableObj.IsNil());

	// bind the __object field in lua to this object
	LuaPlus::LuaObject boxedPtr = pStateManager->GetLuaState()->BoxPointer(this);
	boxedPtr.SetMetaTable(metaTableObj);
	m_ScriptObject.SetLightUserData("__object", this);
	m_ScriptObject.SetMetaTable(metaTableObj);
}
开发者ID:deanmarsinelli,项目名称:City-Protectors,代码行数:15,代码来源:ScriptComponent.cpp

示例11: 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

示例12: 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

示例13: UnregisterScriptFunctions

void BaseScriptComponent::UnregisterScriptFunctions(void)
{
	LuaPlus::LuaObject metaTableObj = LuaStateManager::Get()->GetGlobalVars().Lookup(METATABLE_NAME);
	if (!metaTableObj.IsNil())
		metaTableObj.AssignNil(LuaStateManager::Get()->GetLuaState());
}
开发者ID:JDHDEV,项目名称:AlphaEngine,代码行数:6,代码来源:BaseScriptComponent.cpp


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