| 
		
	
		| iFondue   Junior Member
 
 Posts: 28
 Threads: 6
 Joined: Apr 2012
 Reputation: 
0
 | 
			| How to make a "Wait" in the script. 
 
				Hello, I'm pretty new to this forum and i have a question.    
I already searched in the forum for answers, but I didn't find anything. 
I know that the title is a little complicated, but I am going to explain what I mean...    
Idea: I am working on a custom story for a week now, but now I am stuck at this problem. I made the player look at the corridor (StartPlayerLookAt). Now I want to light always 2 lamps, lamp after lamp when i enter "ScriptArea_1". But i want that between the lightning of the lamps is always like 0.5 seconds... 
 
I know that i have to do that with a timer (I think?   ), but I don't know how....
 
Could someone expain?    
This is my script:
 
Run when entering map 
void OnEnter()
 
{ 
AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1); 
}
 
void LightOn(string &in asParent, string &in asChild, int alState)  
{ 
	AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1); 
	StartPlayerLookAt("LookFrame", 20, 50, ""); 
	SetLampLit("candlestick_1", true, true); 
	SetLampLit("candlestick_2", true, true);
	Wait 0.5 Seconds 
	Light Lamp 3 and 4 (SetLampLit)
	
	Wait 0.5 Seconds 
	Light Lamp 4 and 5  
(SetLampLit) 
	 
	.......
 
	StopPlayerLookAt(); 
}
 
I think you got the idea... ?
 
Greets
 
-iFondue
			 |  |  
	| 04-10-2012, 05:13 PM |  |  
	
		| Putmalk   Senior Member
 
 Posts: 290
 Threads: 13
 Joined: Apr 2012
 Reputation: 
15
 | 
			| RE: How to make a "Wait" in the script. 
 
				Here's how I would do it: void LightOn(string &in asParent, string &in asChild, int alStat){
 AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
 
 StartPlayerLookAt("LookFrame", 20, 50, "");
 
 SetLampLit("candlestick_1", true, true);
 
 SetLampLit("candlestick_2", true, true);
 
 
 AddTimer("light1", 0.5f, "TimerLight");
 AddTimer("light2", 1, "TimerLight");
 AddTimer("stopeffects", 1.2f, "TimerLight");
 
 }
 
 void TimerLight(string &in asTimer)
 {
 
 if(asTimer == "light1")
 {
 //Light Lamp 3 and 4 (SetLampLit);
 }
 if(asTimer == "light2")
 {
 //Light Lamp 4 and 5 (SetLampLit)
 }
 if(asTimer == "stopeffects")
 {
 StopPlayerLookAt();
 }
 }
 |  |  
	| 04-10-2012, 05:20 PM |  |  
	
		| iFondue   Junior Member
 
 Posts: 28
 Threads: 6
 Joined: Apr 2012
 Reputation: 
0
 | 
			| RE: How to make a "Wait" in the script. 
 
				Hey, thank you very much for your fast reply.
 It now looks like this:
 
 
 void LightOn(string &in asParent, string &in asChild, int alStat)
 {
 AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
 
 StartPlayerLookAt("LookFrame", 20, 50, "");
 
 SetLampLit("candlestick_1", true, true);
 
 SetLampLit("candlestick_2", true, true);
 
 
 AddTimer("light1", 0.5f, "TimerLight");
 AddTimer("light2", 1, "TimerLight");
 AddTimer("stopeffects", 1.2f, "TimerLight");
 
 }
 
 void TimerLight(string &in asTimer)
 {
 
 if(asTimer == "light1")
 {
 SetLampLit("candlestick_3", true, true);
 SetLampLit("candlestick_4", true, true);
 }
 if(asTimer == "light2")
 {
 SetLampLit("candlestick_5", true, true);
 SetLampLit("candlestick_6", true, true);
 }
 if(asTimer == "stopeffects")
 {
 StopPlayerLookAt();
 }
 }
 
 
 Unfortunately the other lamps won't light. Did I do something wrong? Did I forget something?
 
 
 Greets
 
 -iFondue
 |  |  
	| 04-10-2012, 05:36 PM |  |  
	
		| Putmalk   Senior Member
 
 Posts: 290
 Threads: 13
 Joined: Apr 2012
 Reputation: 
15
 | 
			| RE: How to make a "Wait" in the script. 
 
				I just double checked the code...it should be fine...
 Could you add a test SetMessage or something inside the if statements to make sure they're running?
 
 
 |  |  
	| 04-10-2012, 05:42 PM |  |  
	
		| iFondue   Junior Member
 
 Posts: 28
 Threads: 6
 Joined: Apr 2012
 Reputation: 
0
 | 
			| RE: How to make a "Wait" in the script. 
 
				Hmmmm... I tried to do a PlaySoundAtEntity but I couldn't hear anything.... Any ideas?
 
 Greets
 
 -iFondue
 |  |  
	| 04-10-2012, 05:48 PM |  |  
	
		| Putmalk   Senior Member
 
 Posts: 290
 Threads: 13
 Joined: Apr 2012
 Reputation: 
15
 | 
			| RE: How to make a "Wait" in the script. 
 
				I'm having trouble understanding why there's a problem because I performed a similar solution in my own map, here's just a snippet:     AddTimer("opendoor", 0.25f, "TimerOpenDoor");AddTimer("lightsout", 1, "TimerOpenDoor");
 AddTimer("stopeffects", 2, "TimerOpenDoor");
 
 StartScreenShake(0.007f,2, 0.25f,1);
 FadePlayerFOVMulTo(1.5, 0.5f);
 
 }
 
 void TimerOpenDoor(string &in asTimer)
 {
 
 if(asTimer == "stopeffects")
 {
 
 FadePlayerFOVMulTo(1, 1);
 PlaySoundAtEntity("breath", "react_breath.snt", "Player", 1.0 / 0.75f, false);
 return;
 }
 if(asTimer == "lightsout")
 {
 SetLocalVarInt("lightsout", 1);
 for(int i=4;i<=6;i++)
 SetLampLit("chandelier_simple_short_"+i, false, true);
 for(int i=0;i<=6;i++)
 SetLampLit("LampBlownOut_"+i, false, true);
 PlaySoundAtEntity("breath2", "react_breath.snt", "Player", 1.0 / 1, false);
 return;
 }
 
 PlaySoundAtEntity("Wind", "general_wind_whirl", "Player", 2, false);
 PlaySoundAtEntity("scare", "react_scare.snt", "Player", 0.75f, false);
 
 SetSwingDoorClosed("castle_4", false, false);
 SetSwingDoorDisableAutoClose("castle_4", true);
 
 AddTimer("castle_4", 0.01f, "TimerSwingDoor");
 
 GiveSanityDamage(10, true);
 
 }
^^
 
And that works just fine. Is the code working correctly? The function TimerLight isn't working? This is weird....
 
Outside the if statements, in TimerLight, put a command. If that doesn't work, then the whole function isn't working, and it's just an error when calling it.
 
Oh yeah, so I don't forget, is the script working at all? Are other functions working correctly?
			
 
				
(This post was last modified: 04-10-2012, 05:55 PM by Putmalk.)
 |  |  
	| 04-10-2012, 05:53 PM |  |  
	
		| iFondue   Junior Member
 
 Posts: 28
 Threads: 6
 Joined: Apr 2012
 Reputation: 
0
 | 
			| RE: How to make a "Wait" in the script. 
 
				Well, this is how it looks right:
 
 void TimerLight(string &in asTimer)
 {
 
 if(asTimer == "light1")
 {
 SetLampLit("candlestick_3", true, true);
 SetLampLit("candlestick_4", true, true);
 }
 if(asTimer == "light2")
 {
 SetLampLit("candlestick_5", true, true);
 SetLampLit("candlestick_6", true, true);
 }
 if(asTimer == "stopeffects")
 {
 StopPlayerLookAt();
 }
 }
 
 
 It's correct isn't it?
 There is no error, when starting, it's just that the light's won't lit....
 
 Is there another way to do it, or did I do something wrong?
 
 
 
 Greets
 
 -iFondue
 |  |  
	| 04-10-2012, 06:00 PM |  |  
	
		| Putmalk   Senior Member
 
 Posts: 290
 Threads: 13
 Joined: Apr 2012
 Reputation: 
15
 | 
			| RE: How to make a "Wait" in the script. 
 
				Copied the code into Programmer's Notepad so I can see it easier, let's see...
 void LightOn(string &in asParent, string &in asChild, int alStat) should be
 
 void LightOn(string &in asParent, string &in asChild, int alState), try that....
 
 Also, In your LightOn function, you're creating an entity collide callback to LightOn, how come? Shouldn't that be placed in OnStart()?
 
 
 
				
(This post was last modified: 04-10-2012, 06:10 PM by Putmalk.)
 |  |  
	| 04-10-2012, 06:09 PM |  |  
	
		| iFondue   Junior Member
 
 Posts: 28
 Threads: 6
 Joined: Apr 2012
 Reputation: 
0
 | 
			| RE: How to make a "Wait" in the script. 
 
				Okay, I changed the State. But what has to go to OnStart () ? Only the LightOn function?
 
 
 Greets
 
 -iFondue
 |  |  
	| 04-10-2012, 06:27 PM |  |  
	
		| Putmalk   Senior Member
 
 Posts: 290
 Threads: 13
 Joined: Apr 2012
 Reputation: 
15
 | 
			| RE: How to make a "Wait" in the script. 
 
				 (04-10-2012, 06:27 PM)iFondue Wrote:  Okay, I changed the State. But what has to go to OnStart () ? Only the LightOn function?
 
 
 Greets
 
 -iFondue
 Nah, "AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);" does.
 
Generally, you put your callbacks in the OnStart function, unless you want that event to happen at a specific time, at which you'll put it in a different place.
			 
 |  |  
	| 04-10-2012, 06:30 PM |  |  |