void ArenaLocker::_handleScript() { LuaManager* lua = LuaManager::getSingletonPtr(); lua->clearLuaStack(); lua->prepFunction("Arena_CameraMovement"); //lua->pushFunctionArgVector(_camera->getPosition()); if(_deltaTime == 0) { lua->pushFunctionArg(16.0f); } else { lua->pushFunctionArg(_deltaTime); } lua->callFunction(1,3); //check for returned values lua_State* luaS = lua->getLuaState(); //assume it's a vector that's being returned. Otherwise some seriously f****d up shit is going on. Ogre::Vector3 targetVector = Ogre::Vector3::UNIT_X; Ogre::Vector3 lookVector = Ogre::Vector3::UNIT_X; if(lua_istable(luaS,1)) { targetVector = LuaManager::getVectorFromLua(luaS,1); } if(lua_istable(luaS,2)) { lookVector = LuaManager::getVectorFromLua(luaS,2); } //Movement time if(lua_isnumber(luaS,3)) { _cameraMovementTime = lua_tonumber(luaS,3); } else { _cameraMovementTime = 0.0f; } //Target Vector if(targetVector == Ogre::Vector3::ZERO) { _stateShutdown = true; } else { _cameraPositionTarget = targetVector; } //Look vector if(lookVector != Ogre::Vector3::ZERO) { //lookVector = _camera->getPosition() + lookVector; if(lookVector != _oldCameraLookTarget) { std::cout << "CameraLookTarget changed!" << std::endl; std::cout << "New LookTarget:" << lookVector << std::endl; _oldCameraLookTarget = _cameraLookTarget; _cameraLookTarget = lookVector; _oldCameraOrientation = _camera->getOrientation(); } } /* _cameraMovementTime += .001f; if(_cameraMovementTime > 1.0f) { _cameraMovementTime = 0.0f; } LuaManager::getSingletonPtr()->clearLuaStack(); LuaManager::getSingletonPtr()->prepFunction("Bezier_Test"); LuaManager::getSingletonPtr()->pushFunctionArg(_cameraMovementTime); //LuaManager::getSingletonPtr()->_printStack(); LuaManager::getSingletonPtr()->callFunction(1,1); //get the vector from it. Ogre::Vector2 tmp = Ogre::Vector2::ZERO; lua_State* l = LuaManager::getSingleton().getLuaState(); if(lua_istable(l,1)) { for(int i = 1; i < 3; ++i) { lua_pushnumber(l,i); lua_gettable(l,1); if(lua_isnumber(l,-1)) { tmp[i-1] = static_cast<float>(lua_tonumber(l,-1)); } else { tmp[i-1] = 0; } lua_pop(l,1); } } if(tmp != Ogre::Vector2::ZERO) { _sphere->setPosition(tmp.x,1.0f,tmp.y); } LuaManager::getSingletonPtr()->clearLuaStack(); */ //handle updating the camera in another function. //keeps this one cleaner. return; }