Game Development Community

a scenario

by rennie moffat · in Torque Game Builder · 02/22/2010 (6:33 pm) · 2 replies

I have this scenario, where by one event upon completion is to trigger another event, but only if a certain condition is true.

my question is, if the condition is at first false (not allowing the function to run) will the computer continually check until it is true?



function starsStar2Behavior::moveToWait(%this)
{
	%this.owner.setPosition(%this.waitPos);
	%this.owner.setLinearVelocityY(%this.stopStar);
	%this.checkLoaderStatus();
}

function starsStar2Behavior::checkLoaderStatus(%this)
{
	if($starsStar1Mounted == true)
	{
		%this.schedule(%this.loadDelay, loadStar);
	}
}

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
02/22/2010 (6:48 pm)
To do this you could add an else statement like this:

function starsStar2Behavior::checkLoaderStatus(%this)   
{   
    if($starsStar1Mounted == true)   
    {   
        %this.schedule(%this.loadDelay, loadStar);   
    } else
    {
        %this.schedule(500, moveToWait);
     }
}

Or the better way would be to put all your checking routine in the onUpdate function of the behavior. Then enable onUpdate.
#2
02/22/2010 (7:20 pm)
right,
i had actually set up an onUpdate, with the calls for setting up the conditions like...

function starsStar2Behavior::onUpdate(%this)
{
	$starsStar2Pos = %this.owner.getPosition();
	
	if(t2dVectorCompare($starsStar2Pos, %this.laodPos))
	{
		$starsStar2Loaded = true;
	}
	
	if(t2dVectorCompare($starsStar2Pos, %this.waitPos))
	{
		$starsStar2Waiting = true;	
	}
	
	$starsStar2Mounted = %this.owner.getIsMounted();
}

then if any condition is called, in an if, later in any behavior I would think it should work right as in...

function starsStar2Behavior::checkLoaderStatus(%this)
{
	if($starsStar1Mounted == true)
	{
		%this.schedule(%this.loadDelay, loadStar);
	}
}


but I am experiencing some troubles tho.