本文整理汇总了C++中luaplus::LuaObject类的典型用法代码示例。如果您正苦于以下问题:C++ LuaObject类的具体用法?C++ LuaObject怎么用?C++ LuaObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LuaObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Wrap
static LuaPlus::LuaObject Wrap(Vec3 vector){
LuaPlus::LuaObject vecObj;
vecObj.AssignNewTable(LuaManager::Get()->GetState());
vecObj.SetNumber("x", vector.x);
vecObj.SetNumber("y", vector.y);
vecObj.SetNumber("z", vector.z);
return vecObj;
}
示例2: ApplyTorque
// apply torque to an object from lua
void LuaInternalScriptExports::ApplyTorque(LuaPlus::LuaObject axisLua, float force, int gameObjectId)
{
if (axisLua.IsTable())
{
Vec3 axis(axisLua["x"].GetFloat(), axisLua["y"].GetFloat(), axisLua["z"].GetFloat());
g_pApp->m_pGame->GetGamePhysics()->ApplyTorque(axis, force, gameObjectId);
return;
}
CB_ERROR("Invalid object passed to ApplyForce(). Type = " + std::string(axisLua.TypeName()));
}
示例3: registerScripts
void LuaScriptExports::registerScripts( void )
{
LuaPlus::LuaObject globals = LuaStateManager::instance()->getGlobalVars();
// Init
InternalLuaScriptExports::init();
// Resource loading
globals.RegisterDirect("loadAndExecuteScriptResource",InternalLuaScriptExports::loadAndExecutreScriptResource);
// Process manager
globals.RegisterDirect("attachProcess",&InternalLuaScriptExports::attachScriptProcess);
// Event system
globals.RegisterDirect("registerEventListener", &InternalLuaScriptExports::registerEventListener);
globals.RegisterDirect("removeEventListener", &InternalLuaScriptExports::removeEventListener);
globals.RegisterDirect("queueEvent", &InternalLuaScriptExports::queueEvent);
globals.RegisterDirect("triggerEvent", &InternalLuaScriptExports::triggerEvent);
// Actors
globals.RegisterDirect("createActor", &InternalLuaScriptExports::createActor);
// Lua log
globals.RegisterDirect("log",&InternalLuaScriptExports::lualog);
}
示例4: LuaLog
// write to the log from lua script
void LuaInternalScriptExports::LuaLog(LuaPlus::LuaObject text)
{
if (text.IsConvertibleToString())
{
CB_LOG("Lua", text.ToString());
}
else
{
CB_LOG("Lua", "<" + std::string(text.TypeName()) + ">");
}
}
示例5:
void ant::InternalLuaScriptExports::lualog( LuaPlus::LuaObject text )
{
if (text.IsConvertibleToString())
{
GCC_LOG("Lua",text.ToString());
}
else
{
GCC_LOG("Lua","<" + std::string(text.TypeName()) + ">");
}
}
示例6: GetLookAt
LuaPlus::LuaObject BaseScriptComponent::GetLookAt(void) const
{
LuaPlus::LuaObject ret;
shared_ptr<TransformComponent> pTransformComponent = MakeStrongPtr(m_pOwner->GetComponent<TransformComponent>(TransformComponent::g_Name));
if (pTransformComponent)
LuaStateManager::Get()->ConvertVec3ToTable(pTransformComponent->GetLookAt(), ret);
else
ret.AssignNil(LuaStateManager::Get()->GetLuaState());
return ret;
}
示例7: 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");
}
}
示例8: GetYRotationFromVector
// get the y rotation in radians from a lua vec3
float LuaInternalScriptExports::GetYRotationFromVector(LuaPlus::LuaObject vec3)
{
// make sure vec3 is a table
if (vec3.IsTable())
{
Vec3 lookAt(vec3["x"].GetFloat(), vec3["y"].GetFloat(), vec3["z"].GetFloat());
// use the GetYRotationFromVector from math.h
return ::GetYRotationFromVector(lookAt);
}
CB_ERROR("Invalid object passed to GetYRotationFromVector(); type = " + std::string(vec3.TypeName()));
return 0;
}
示例9: 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");
}
}
示例10: GetPos
LuaPlus::LuaObject LuaScriptComponent::GetPos()
{
// return the objects position to lua
LuaPlus::LuaObject ret;
shared_ptr<TransformComponent> pTransformComponent = MakeStrongPtr(m_pOwner->GetComponent<TransformComponent>(TransformComponent::g_Name));
if (pTransformComponent)
LuaStateManager::Get()->ConvertVec3ToTable(pTransformComponent->GetPosition(), ret);
else
ret.AssignNil(LuaStateManager::Get()->GetLuaState());
return ret;
}
示例11: 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);
}
示例12: GetVectorFromRotation
// create a lua vec3 table from an angle in radians
LuaPlus::LuaObject LuaInternalScriptExports::GetVectorFromRotation(float angleRadians)
{
// use the GetVectorFromYRotation from math.h
Vec3 result = ::GetVectorFromYRotation(angleRadians);
// create a lua vec3 table from the result
LuaPlus::LuaObject luaResult;
luaResult.AssignNewTable(LuaStateManager::Get()->GetLuaState());
luaResult.SetNumber("x", result.x);
luaResult.SetNumber("y", result.y);
luaResult.SetNumber("z", result.z);
return luaResult;
}
示例13: 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);
}
示例14: 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;
}
示例15: 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);
}