示例#1
0
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;
}
示例#2
0
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;
}