void AvHScriptManager::Reset() { for(AvHScriptInstanceListType::iterator theIter = this->mScriptList.begin(); theIter != this->mScriptList.end(); theIter++) { theIter->Reset(); } this->mScriptList.clear(); }
void AvHScriptManager::ClientUpdate(float inTimePassed) { #ifdef USE_LUA // For all scripts for(AvHScriptInstanceListType::iterator theIter = this->mScriptList.begin(); theIter != this->mScriptList.end(); /* no increment */) { // Call "clientUpdate(inTimePassed)" function (push function then args) lua_getglobal(theIter->GetState(), "clientUpdate"); // Push time passed lua_pushnumber(theIter->GetState(), inTimePassed); // Push num args and num return lua_call(theIter->GetState(), 1, 1); // If function returns false, delete it bool theKeepRunning = true; int theNumReturned = lua_gettop(theIter->GetState()); if(theNumReturned > 0) { string theString = lua_tostring(theIter->GetState(), 1); theKeepRunning = lua_tonumber(theIter->GetState(), 1); lua_pop(theIter->GetState(), 1); } if(!theKeepRunning) { theIter->Reset(); theIter = this->mScriptList.erase(theIter); } else { // else increment theIter++; } } #endif }