The worst submarine 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 11 
	Threads: 2 
	Joined: Oct 2010
	
 Reputation: 
0
		
	 | 
	
		
			
Code help: Trigger when lit 
			 
			
				Hi! I'm trying to have the 01_house.map load when the player turns on candlestick1, but I am miserable when it comes to code. Can anyone lend me a hand? Thanks.   
			 
			
			
			
		 |  
	 
 | 
 
	| 10-02-2010, 09:03 PM  | 
	
		
	 | 
 
 
	
		
		HakePT 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 49 
	Threads: 1 
	Joined: Sep 2010
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Code help: Trigger when lit 
			 
			
				Don't think you can make a player change lvls on anything other than a lvl door. 
Still there may be a way but i don't know it.
			 
			
			
			
		 |  
	 
 | 
 
	| 10-02-2010, 09:38 PM  | 
	
		
	 | 
 
 
	
		
		Jordo76 
 
 
		
			Member 
			
			
			
 
			
	Posts: 57 
	Threads: 7 
	Joined: Sep 2010
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Code help: Trigger when lit 
			 
			
				It's possible : 
CODE : 
void InteractCandle(string &in asEntity) 
{ 
ChangeMap("01_house","StartPosHere","StartSoundHere","EndSoundHere"); 
} 
NON CODE : 
Put InteractCandle in Interact Callback of the Candle (in the editor)
 It MIGHT work
 
Edit : Work but it work even if you haven't any Tinderbox,Make sure the player has one tinderbox so he will light her automatically
			  
			
			
			
		 |  
	 
 | 
 
	| 10-02-2010, 09:46 PM  | 
	
		
	 | 
 
 
	
		
		The worst submarine 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 11 
	Threads: 2 
	Joined: Oct 2010
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Code help: Trigger when lit 
			 
			
				 (10-02-2010, 10:29 PM)The worst submarine Wrote:  Thanks! I'll give it a shot and report back. Worked like a charm! I think to fix the no-tinderbox problem, I'll have the candle disappear until a player gets a tinderbox, replaced by a candle without the callback function. Once they have one, it'll reappear.
			  
			
			
			
		 |  
	 
 | 
 
	| 10-02-2010, 10:29 PM  | 
	
		
	 | 
 
 
	
		
		Noj 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 11 
	Threads: 2 
	Joined: Oct 2010
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Code help: Trigger when lit 
			 
			
				 (10-02-2010, 10:29 PM)The worst submarine Wrote:   (10-02-2010, 10:29 PM)The worst submarine Wrote:  Thanks! I'll give it a shot and report back. Worked like a charm! I think to fix the no-tinderbox problem, I'll have the candle disappear until a player gets a tinderbox, replaced by a candle without the callback function. Once they have one, it'll reappear. 
cant you just do a if condition in the script?  
scripting fuctions in the documents says theres bool hasitem 
you should be able to use that. (I havent started any scripting yet so i acnt answer on how...)
			  
			
			
			
		 |  
	 
 | 
 
	| 10-02-2010, 11:15 PM  | 
	
		
	 | 
 
 
	
		
		The worst submarine 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 11 
	Threads: 2 
	Joined: Oct 2010
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Code help: Trigger when lit 
			 
			
				 (10-02-2010, 11:15 PM)Noj Wrote:  cant you just do a if condition in the script?  
scripting fuctions in the documents says theres bool hasitem 
you should be able to use that. (I havent started any scripting yet so i acnt answer on how...) Yeah I noticed that too, it seems a lot easier. Thanks.   
			 
			
			
			
		 |  
	 
 | 
 
	| 10-02-2010, 11:18 PM  | 
	
		
	 | 
 
 
	
		
		Entih 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 47 
	Threads: 4 
	Joined: Sep 2010
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Code help: Trigger when lit 
			 
			
				Candles actually have an option in their entity options called CallbackFunc, and one of the Types it can function as is 'OnIgnite', much easier with much less inventory checking.  Basically, you define a function name for it to point to, for example I tested it with 'testignite' as the function name.  Then, in your script, you have something like this: 
void testignite(string &in EntityName, string &in Type) 
{ 
    if(Type == "OnIgnite") 
    { 
        AddDebugMessage("Ignited_callback_scare", false); 
        PlaySoundAtEntity("rawr", "guardian_ontop.snt", "Player", 0.0f, false); 
    } 
}
 
In that fully functional sample, when the candle is ignited with a tinderbox, it sends out a debug message and a scary sound.
			  
			
			
			
		 |  
	 
 | 
 
	| 10-03-2010, 03:19 AM  | 
	
		
	 | 
 
 
	
		
		The worst submarine 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 11 
	Threads: 2 
	Joined: Oct 2010
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Code help: Trigger when lit 
			 
			
				 (10-03-2010, 03:19 AM)Entih Wrote:  Candles actually have an option in their entity options called CallbackFunc, and one of the Types it can function as is 'OnIgnite', much easier with much less inventory checking.  Basically, you define a function name for it to point to, for example I tested it with 'testignite' as the function name.  Then, in your script, you have something like this: 
 
void testignite(string &in EntityName, string &in Type) 
{ 
    if(Type == "OnIgnite") 
    { 
        AddDebugMessage("Ignited_callback_scare", false); 
        PlaySoundAtEntity("rawr", "guardian_ontop.snt", "Player", 0.0f, false); 
    } 
}
  
In that fully functional sample, when the candle is ignited with a tinderbox, it sends out a debug message and a scary sound. I finally got the code working, and then I decided to come back and say that I'd finished. Now I find a much, much easier way to do what I've done! Haha. Thanks, I'll definitely replace my code with this. Much less loopholes.
			  
			
			
			
		 |  
	 
 | 
 
	| 10-03-2010, 03:27 AM  | 
	
		
	 | 
 
 
	 
 |