Exemple #1
0
void AvHScriptManager::DrawNoZBuffering()
{
	// For all scripts
	for(AvHScriptInstanceListType::iterator theIter = this->mScriptList.begin(); theIter != this->mScriptList.end(); theIter++)
	{
		theIter->CallSimpleFunction("drawNoZBuffering");
	}
}
Exemple #2
0
void AvHScriptManager::Reset()
{
	for(AvHScriptInstanceListType::iterator theIter = this->mScriptList.begin(); theIter != this->mScriptList.end(); theIter++)
	{
		theIter->Reset();
	}
	this->mScriptList.clear();
}
Exemple #3
0
void AvHScriptManager::Update(float inTime)
{
	// Run through list of scripts
	for(AvHScriptInstanceListType::iterator theIter = this->mScriptList.begin(); theIter != this->mScriptList.end(); /* no increment */)
	{
		// If callback is pending
		if(theIter->CallbacksPending())
		{
			// Is it time to run any of our callbacks?
			theIter->Update(inTime);
			
			// Always increment
			theIter++;
		}
		// else
		else
		{
			// Remove it from the list
			theIter = this->mScriptList.erase(theIter);
		}
	}
}
Exemple #4
0
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
}
Exemple #5
0
bool AvHScriptManager::GetClientMove(int& outButtonBits, int& outImpulse)
{
	bool theSuccess = false;
#ifdef USE_LUA

	#ifdef DEBUG

	// For all scripts
	for(AvHScriptInstanceListType::iterator theIter = this->mScriptList.begin(); theIter != this->mScriptList.end(); theIter++)
	{
		// Call getClientMove() on script.  If it is successful, stop processing.  Only one script can control movement at a time
		const int kNumExpectedReturnValues = 2;

		// Execute callback
		lua_getglobal(theIter->GetState(), "getClientMove");
		lua_call(theIter->GetState(), 0, kNumExpectedReturnValues);

		// Check for success
		int theNumReturned = lua_gettop(theIter->GetState());
		if(theNumReturned >= kNumExpectedReturnValues)
		{
			// Populating move structure if possible
			outButtonBits = (int)lua_tonumber(theIter->GetState(), 1);
			outImpulse = (int)lua_tonumber(theIter->GetState(), 2);

			lua_pop(theIter->GetState(), kNumExpectedReturnValues);

			theSuccess = true;
		}

		if(theSuccess)
		{
			break;
		}
	}

	#endif

#endif
	return theSuccess;
}