本文整理汇总了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");
}
}
示例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());
}
示例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));
}
}
示例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;
}
示例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");
}
}
示例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");
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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!");
}
示例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;
}
示例13: UnregisterScriptFunctions
void BaseScriptComponent::UnregisterScriptFunctions(void)
{
LuaPlus::LuaObject metaTableObj = LuaStateManager::Get()->GetGlobalVars().Lookup(METATABLE_NAME);
if (!metaTableObj.IsNil())
metaTableObj.AssignNil(LuaStateManager::Get()->GetLuaState());
}