Akasu   
 
 
		
			Member 
			
			
			
 
			
	Posts: 62 
	Threads: 6 
	Joined: Aug 2010
	
 Reputation: 
2  
		 
	 
	
		
			
RE: Need help with a script (again) 
  
			 
			
				That did it. Thanks for bothering 
 Always nice to learn stuff.
E: Yep. Definately works.
Final product 
Spoiler below!   
void OnStart () 
{ 
AddEntityCollideCallback("box1","area_red","BOX1LIGHT", false, 0); 
AddEntityCollideCallback("box1","area_green","BOX1LIGHT", false, 0); 
AddEntityCollideCallback("box1","area_blue","BOX1LIGHT", false, 0); 
AddEntityCollideCallback("box2","area_red","BOX1LIGHT", false, 0); 
AddEntityCollideCallback("box2","area_green","BOX1LIGHT", false, 0); 
AddEntityCollideCallback("box2","area_blue","BOX1LIGHT", false, 0); 
AddEntityCollideCallback("box3","area_red","BOX1LIGHT", false, 0); 
AddEntityCollideCallback("box3","area_green","BOX1LIGHT", false, 0); 
AddEntityCollideCallback("box3","area_blue","BOX1LIGHT", false, 0); 
SetLocalVarInt("RedLightOn", 1); 
SetLocalVarInt("GreenLightOn", 1); 
SetLocalVarInt("BlueLightOn", 1); 
SetLightVisible("redy", false); 
SetLightVisible("greeny", false); 
SetLightVisible("bluey", false); 
} 
 
void BOX1LIGHT(string &in asParent, string &in asChild, int alState) 
{ 
if(asChild == "area_red") { 
if(GetLocalVarInt("RedLightOn") == 1) SetLocalVarInt("RedLightOn", 0); 
else SetLocalVarInt("RedLightOn", 1); 
 
if(GetLocalVarInt("RedLightOn") == 1) SetLightVisible("redy", false); 
else SetLightVisible("redy", true); 
} 
 
if(asChild == "area_green") { 
if(GetLocalVarInt("GreenLightOn") == 1) SetLocalVarInt("GreenLightOn", 0); 
else SetLocalVarInt("GreenLightOn", 1); 
 
if(GetLocalVarInt("GreenLightOn") == 1) SetLightVisible("greeny", false); 
else SetLightVisible("greeny", true); 
 
} 
 
if(asChild == "area_blue") { 
if(GetLocalVarInt("BlueLightOn") == 1) SetLocalVarInt("BlueLightOn", 0); 
else SetLocalVarInt("BlueLightOn", 1); 
 
if(GetLocalVarInt("BlueLightOn") == 1) SetLightVisible("bluey", false); 
else SetLightVisible("bluey", true); 
} 
} 
 
 
			 
			
			
			
		  
	
 
 
	09-22-2010, 09:25 PM   
	
		
	 
 
	
		 
		jens   
 
 
		
			Frictional Games 
			
			
			
 
			
	Posts: 4,093 
	Threads: 199 
	Joined: Apr 2006
	
 Reputation: 
202  
		 
	 
	
		
			
RE: Need help with a script (again) 
  
			 
			
				To simplify it, skip the LocalVars all together and use a better naming on your areas and light that way you can make this really simple.
void BOX1LIGHT(string &in asParent, string &in asChild, int alState) 
{ 
    if(alState == 1) 
    { 
        SetLightVisible(asChild+"_light", true); 
    } 
    else if(alState == -1) 
    { 
        SetLightVisible(asChild+"_light", false); 
    } 
}
So you check the variable that tells you if something enters or leaves the area, that is alState. 
Then if you name you lights the same as the area but suffix them with _light, you can use the variable with the name of the area to not write everything specific.
Example: Area is named "MyArea", you name the light "MyArea_Light", in the script you then use asChild+"_Light" which is the same as "MyArea_Light" because asChild is the variable containing what area it is that something entered into.
			
 
			
			
			
				
(This post was last modified: 09-23-2010, 06:36 AM by jens .) 
 
				
			 
		  
	
 
 
	09-23-2010, 06:34 AM   
	
		
	 
 
	
		 
		Akasu   
 
 
		
			Member 
			
			
			
 
			
	Posts: 62 
	Threads: 6 
	Joined: Aug 2010
	
 Reputation: 
2  
		 
	 
	
		
			
RE: Need help with a script (again) 
  
			 
			
				Well that is  simple. I'll use it. Thanks.  
Will keep the Pandemoneous's script somewhere in case I need to use local variables sometime.
			
			
			
			
		  
	
 
 
	09-23-2010, 10:44 AM   
	
		
	 
 
	
		 
		MulleDK19   
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 545 
	Threads: 21 
	Joined: Jun 2009
	
 Reputation: 
10  
		 
	 
	
		
			
RE: Need help with a script (again) 
  
			 
			
				void OnStart() 
{ 
    SetLightVisible("redy", false); 
    AddEntityCollideCallback("box1","area_red","BOX1RED", false, 0); 
} 
 
void BOX1RED(string &in asParent, string &in asChild, int alState) 
{ 
    if(asChild == "area_red") 
        SetLightVisible("redy", (alState > 0)); 
}
 
			 
			
			
 
			
		  
	
 
 
	09-23-2010, 05:56 PM