本文整理汇总了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());
}
示例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));
}
}
示例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!");
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}