本文整理汇总了C++中luaplus::LuaObject::TypeName方法的典型用法代码示例。如果您正苦于以下问题:C++ LuaObject::TypeName方法的具体用法?C++ LuaObject::TypeName怎么用?C++ LuaObject::TypeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类luaplus::LuaObject
的用法示例。
在下文中一共展示了LuaObject::TypeName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createActor
int ant::InternalLuaScriptExports::createActor( const char* actorArchetype, LuaPlus::LuaObject luaPosition, LuaPlus::LuaObject luaRotation )
{
if (!luaPosition.IsTable())
{
GCC_ERROR("Invalid object passed to createActor(); type = " + std::string(luaPosition.TypeName()));
return INVALID_ACTOR_ID;
}
if (!luaRotation.IsNumber())
{
GCC_ERROR("Invalid object passed to createActor(); type = " + std::string(luaRotation.TypeName()));
return INVALID_ACTOR_ID;
}
sf::Vector2f pos(luaPosition["x"].GetFloat(), luaPosition["y"].GetFloat());
ant::Real rot = luaRotation.GetFloat();
TiXmlElement *overloads = NULL;
ActorStrongPtr actor = ant::ISFMLApp::getApp()->getGameLogic()->createActor(actorArchetype, overloads, &pos, &rot);
if (actor)
{
shared_ptr<EvtData_New_Actor> pNewActorEvent(GCC_NEW EvtData_New_Actor(actor->getId()));
IEventManager::instance()->queueEvent(pNewActorEvent);
return actor->getId();
}
return INVALID_ACTOR_ID;
}
示例2: buildEventFromScript
bool EvtData_StartJump::buildEventFromScript(void)
{
if (m_eventData.IsTable())
{
// ID
LuaPlus::LuaObject temp = m_eventData.GetByName("actorId");
if (temp.IsInteger())
{
m_id = temp.GetInteger();
}
else
{
GCC_ERROR("Invalid id sent to EvtData_StartJump; type = " + std::string(temp.TypeName()));
return false;
}
// acceleration
temp = m_eventData.GetByName("acceleration");
if (temp.IsNumber())
m_acceleration = temp.GetFloat();
else
m_acceleration = 5.0f; // something reasonable
return true;
}
return false;
}
示例3: ApplyForce
// apply force to an object from lua
void LuaInternalScriptExports::ApplyForce(LuaPlus::LuaObject normalDirectionLua, float force, int gameObjectId)
{
if (normalDirectionLua.IsTable())
{
Vec3 normalDir(normalDirectionLua["x"].GetFloat(), normalDirectionLua["y"].GetFloat(), normalDirectionLua["z"].GetFloat());
g_pApp->m_pGame->GetGamePhysics()->ApplyForce(normalDir, force, gameObjectId);
return;
}
CB_ERROR("Invalid object passed to ApplyForce(). Type = " + std::string(normalDirectionLua.TypeName()));
}
示例4: ApplyTorque
void InternalScriptExports::ApplyTorque(LuaPlus::LuaObject axisLua, float force, int actorId)
{
if (axisLua.IsTable())
{
Vec3 axis(axisLua["x"].GetFloat(), axisLua["y"].GetFloat(), axisLua["z"].GetFloat());
g_pApp->m_pGame->VGetGamePhysics()->VApplyTorque(axis, force, actorId);
return;
}
GCC_ERROR("Invalid object passed to ApplyTorque(); type = " + std::string(axisLua.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: 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()) + ">");
}
}
示例7: 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;
}
示例8: CreateGameObject
// create a game object from lua
int LuaInternalScriptExports::CreateGameObject(const char* objectArchetype, LuaPlus::LuaObject luaPosition, LuaPlus::LuaObject luaYawPitchRoll)
{
// lua position must be a table
if (!luaPosition.IsTable())
{
CB_ERROR("Invalid object passed to CreateGameObject(). Type = " + std::string(luaPosition.TypeName()));
return INVALID_GAMEOBJECT_ID;
}
// lua yawPitchRoll must be a table
if (!luaYawPitchRoll.IsTable())
{
CB_ERROR("Invalid object passed to CreateGameObject(). Type = " + std::string(luaYawPitchRoll.TypeName()));
return INVALID_GAMEOBJECT_ID;
}
Vec3 position(luaPosition["x"].GetFloat(), luaPosition["y"].GetFloat(), luaPosition["z"].GetFloat());
Vec3 yawPitchRoll(luaYawPitchRoll["x"].GetFloat(), luaYawPitchRoll["y"].GetFloat(), luaYawPitchRoll["z"].GetFloat());
// build the transform for the object
Mat4x4 transform;
transform.BuildYawPitchRoll(yawPitchRoll.x, yawPitchRoll.y, yawPitchRoll.z);
transform.SetPosition(position);
// create the object
TiXmlElement* overloads = nullptr;
StrongGameObjectPtr pObject = g_pApp->m_pGame->CreateGameObject(objectArchetype, overloads, &transform);
// fire the new object created event
if (pObject)
{
shared_ptr<Event_NewGameObject> pNewObjectEvent(CB_NEW Event_NewGameObject(pObject->GetId()));
IEventManager::Get()->QueueEvent(pNewObjectEvent);
return pObject->GetId();
}
return INVALID_GAMEOBJECT_ID;
}
示例9: GetYRotationFromVector
float InternalScriptExports::GetYRotationFromVector(LuaPlus::LuaObject vec3)
{
if (vec3.IsTable())
{
Vec3 lookAt(vec3["x"].GetFloat(), vec3["y"].GetFloat(), vec3["z"].GetFloat());
return ::GetYRotationFromVector(lookAt);
}
GCC_ERROR("Invalid object passed to GetYRotationFromVector(); type = " + std::string(vec3.TypeName()));
return 0;
}
示例10: CreateActor
int InternalScriptExports::CreateActor(const char* actorArchetype, LuaPlus::LuaObject luaPosition, LuaPlus::LuaObject luaYawPitchRoll)
{
if (!luaPosition.IsTable())
{
GCC_ERROR("Invalid object passed to CreateActor(); type = " + std::string(luaPosition.TypeName()));
return INVALID_ACTOR_ID;
}
if (!luaYawPitchRoll.IsTable())
{
GCC_ERROR("Invalid object passed to CreateActor(); type = " + std::string(luaYawPitchRoll.TypeName()));
return INVALID_ACTOR_ID;
}
Vec3 pos(luaPosition["x"].GetFloat(), luaPosition["y"].GetFloat(), luaPosition["z"].GetFloat());
Vec3 ypr(luaYawPitchRoll["x"].GetFloat(), luaYawPitchRoll["y"].GetFloat(), luaYawPitchRoll["z"].GetFloat());
Mat4x4 initialTransform;
initialTransform.BuildYawPitchRoll(ypr.x, ypr.y, ypr.z);
initialTransform.SetPosition(pos);
TiXmlElement *overloads = NULL;
StrongActorPtr pActor = g_pApp->m_pGame->VCreateActor(actorArchetype, overloads, &initialTransform);
if (pActor)
{
shared_ptr<EvtData_New_Actor> pNewActorEvent(GCC_NEW EvtData_New_Actor(pActor->GetId()));
IEventManager::Get()->VQueueEvent(pNewActorEvent);
return pActor->GetId();
}
return INVALID_ACTOR_ID;
}