Sign in to follow this  
Followers 0
itstruestu

Oh baby a triple!! (help w/ checking 3 global variables)

3 posts in this topic

FqQds3K.jpg?1eEMgmIX.jpg?1

 

Hi there, currently having problems coding a minigame that involves hitting a triple.

I have 4 functions in total. The first 3 check each target constantly, to see if it has been hit. It then assigns a global variable to =1 for a short while. These seem to be working.

 

However, the 4th one doesn't seem to work, which checks the 3 global variables, and if they all = 1 it initiates  a sound. 

Currently I have it only checking 2 variables (because even THAT doesn't work...) 

Can you help?

 

Please also note, the iprintln "else" should be showing up every 100ms, but it doesn't.

zoneD1Bii()												//Target #2
{
targetD1B=getEnt ("targetD1B", "targetname");
   
        while(1)
        {
			targetD1B waittill ("trigger",player);		//waiting for the target to be shot
			iprintln ("hit target B");
			level.targetHitD1B = 1;						//globally acknowledging that the target has been shot
			wait 0.5; 									//waiting for other targets to be sensed
			level.targetHitD1B = 0;						//resetting variable - allowing user to try again
        }
}

zoneD1Cii()												//Target #3
{
targetD1C=getEnt ("targetD1C", "targetname");
   
        while(1)
        {
			targetD1C waittill ("trigger",player);		//waiting for the target to be shot
			iprintln ("hit target C");
			level.targetHitD1C = 1;						//globally acknowledging that the target has been shot
			wait 0.5; 									//waiting for other targets to be sensed
			level.targetHitD1C = 0;						//resetting variable - allowing user to try again
        }
}

zoneD1Aii()												//Target #3
{
targetD1A=getEnt ("targetD1A", "targetname");
   
        while(1)
        {
			targetD1A waittill ("trigger",player);		//waiting for the target to be shot
			iprintln ("hit target A");
			level.targetHitD1A = 1;						//globally acknowledging that the target has been shot
			wait 0.5; 									//waiting for other targets to be sensed
			level.targetHitD1A = 0;						//resetting variable - allowing user to try again
        }
}
 
tripleD1ii()
{
	while(1)	
		wait 0.1;													
															iprintln ("waiting");
		if (level.targetHitD1B == 1 && level.targetHitD1C == 1)	//checks if the variables for the 2nd and 3rd target are 1 -aka has it been shot-
			{
			iprintln ("^7oh baby a triple");		//all 3 targets were hit at once!
			AmbientPlay ("triple");
			wait 0.2;
			}
		else
			{
			wait 0.2;	
			iprintln ("else");
			}
}
 
tripleD1()
{
//oh_baby_a_triple = getent ("ohbabybrush", "targetname");
	targetD1A=getEnt ("targetD1A", "targetname");	
	while(1)	
		targetD1A waittill ("trigger",player);					//waiting for 3rd target to be shot
		wait 0.1;													
															iprintln ("hit target A");
		if (self.targetHitD1B == 1 && self.targetHitD1C == 1)	//checks if the variables for the 2nd and 3rd target are 1 -aka has it been shot-
			{
			iprintln ("^7oh baby a triple");		//all 3 targets were hit at once!
			AmbientPlay ("triple");
			
			wait 0.8;
			}
		else
			{
			wait 0.1;											//not all targets are hit
			}
}

 

1

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0