本文整理汇总了C++中luaplus::LuaObject::IsNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ LuaObject::IsNumber方法的具体用法?C++ LuaObject::IsNumber怎么用?C++ LuaObject::IsNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类luaplus::LuaObject
的用法示例。
在下文中一共展示了LuaObject::IsNumber方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetColorFromLua
// /////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////
bool SetColorFromLua(const LuaPlus::LuaObject &colorData, Vector4 &color)
{
if(!colorData.IsTable()) {
return (false);
}
LuaPlus::LuaObject rData = colorData["r"];
LuaPlus::LuaObject gData = colorData["g"];
LuaPlus::LuaObject bData = colorData["b"];
LuaPlus::LuaObject aData = colorData["a"];
if(!rData.IsNumber() || !gData.IsNumber() || !bData.IsNumber() || !aData.IsNumber()) {
return (false);
}
F32 r = static_cast<F32>(rData.GetNumber());
F32 g = static_cast<F32>(gData.GetNumber());
F32 b = static_cast<F32>(bData.GetNumber());
F32 a = static_cast<F32>(aData.GetNumber());
Clamp<F32>(r, 0.0f, 1.0f);
Clamp<F32>(g, 0.0f, 1.0f);
Clamp<F32>(b, 0.0f, 1.0f);
Clamp<F32>(a, 0.0f, 1.0f);
color.Set(r, g, b, a);
return (true);
}
示例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: 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;
}
示例4: SetLuaSliderPosition
// /////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////
void SliderControl::SetLuaSliderPosition(const LuaPlus::LuaObject &table)
{
if(table.IsNumber()) {
m_sliderPos = static_cast<F32>(table.GetNumber());
Clamp(m_sliderPos, 0.0f, 1.0f);
}
}
示例5: SetFloatFromLua
// /////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////
bool SetFloatFromLua(const LuaPlus::LuaObject &numberData, F32 &number)
{
if(!numberData.IsNumber()) {
return (false);
}
number = static_cast<F32>(numberData.GetNumber());
return (true);
}
示例6: return
// /////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////
bool SetVector3FromLua(const LuaPlus::LuaObject &dirData, Vector3 &direction)
{
if(!dirData.IsTable()) {
return (false);
}
LuaPlus::LuaObject xData = dirData["x"];
LuaPlus::LuaObject yData = dirData["y"];
LuaPlus::LuaObject zData = dirData["z"];
if(!xData.IsNumber() || !yData.IsNumber() || !zData.IsNumber()) {
return (false);
}
F32 x = static_cast<F32>(xData.GetNumber());
F32 y = static_cast<F32>(yData.GetNumber());
F32 z = static_cast<F32>(zData.GetNumber());
direction.Set(x, y, z);
return (true);
}
示例7: 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!");
}