| 
		
	
		| No Author   Posting Freak
 
 Posts: 962
 Threads: 10
 Joined: Jun 2012
 Reputation: 
13
 | 
			| Locking Doors ,Give Item ,and Lights 
 
				I'm trying to make a script where the player can lock and unlock the same door. But when I lock it, it doesn't lock the door. Here's my script : void OnStart(){
 AddUseItemCallback("", "key_study", "mansion_1", "UseKeyOnDoor01", true);
 }
 void UseKeyOnDoor01(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("mansion_1", false, true);
 PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
 AddUseItemCallback("", "key_study", "mansion_1", "LockDoor01", true);
 }
 
 void LockDoor01(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("mansion_1", false, true);
 PlaySoundAtEntity("", "lock_door.snt", "mansion_1", 0, true);
 AddUseItemCallback("", "key_study", "mansion_1", "UseKeyOnDoor01", true);
 }
 
When I give the study key using the "GiveItem" Script, the picture on the inventory is like this :
 ![[Image: amnesia2013012216031325.jpg]](http://img826.imageshack.us/img826/8821/amnesia2013012216031325.jpg)  
And I want to make a script where the player can interact with a candle to turn it off if it's lit. I've searched on the engine scripts and I didn't found anything about turning off candles.
			
 ![[Image: the-cabin-in-the-woods-masked-people.jpg]](http://universaldork.files.wordpress.com/2012/04/the-cabin-in-the-woods-masked-people.jpg)
				
(This post was last modified: 01-22-2013, 10:17 AM by No Author.)
 |  |  
	| 01-22-2013, 10:15 AM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: Locking Doors ,Give Item ,and Lights 
 
				For the lock&unlock void OnStart(){
 AddUseItemCallback("", "key_study", "mansion_1", "UseKeyOnDoor01", false);
 }
 
 
 void UseKeyOnDoor01(string &in asItem, string &in asEntity)
 {
 
 if(GetSwingDoorLocked("mansion_1") == true)
 {
 SetSwingDoorLocked("mansion_1", false, true);
 PlaySoundAtEntity("", "lock_door.snt", "mansion_1", 0, true);
 }
 
 if(GetSwingDoorLocked("mansion_1") == false)
 {
 SetSwingDoorLocked("mansion_1", true, true);
 PlaySoundAtEntity("", "lock_door.snt", "mansion_1", 0, true);
 }
 }
Could you show me your "GiveItem" line?
			
 Trying is the first step to success. |  |  
	| 01-22-2013, 11:28 AM |  |  
	
		| No Author   Posting Freak
 
 Posts: 962
 Threads: 10
 Joined: Jun 2012
 Reputation: 
13
 | 
			| RE: Locking Doors ,Give Item ,and Lights 
 
				Here :  void OnStart(){
 GiveItem("key_study", "", "key_study", "key_study_height.tga", 0);
 }
 
 |  |  
	| 01-22-2013, 11:42 AM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: Locking Doors ,Give Item ,and Lights 
 
				key_study_height.tga does not sound like a .tga file.
 
 Isn't it just key_study.tga?
 
 Trying is the first step to success. |  |  
	| 01-22-2013, 11:56 AM |  |  
	
		| No Author   Posting Freak
 
 Posts: 962
 Threads: 10
 Joined: Jun 2012
 Reputation: 
13
 | 
			| RE: Locking Doors ,Give Item ,and Lights 
 
				 (01-22-2013, 11:56 AM)BeeKayK Wrote:  key_study_height.tga does not sound like a .tga file.
 
 Isn't it just key_study.tga?
 
Lol. It works now
			 
 |  |  
	| 01-22-2013, 12:26 PM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: Locking Doors ,Give Item ,and Lights 
 
				void SetLampLit(string& asName, bool abLit, bool abEffects);(Un)lits a lamp.
 asName - Name of the lamp
 abLit - Set true if you want the lamp to be lit, set to false if you want the lamp to be unlit
 abEffects - If you want to have the lamp fade in/out when it gets (un)lit
 
 Trying is the first step to success. |  |  
	| 01-22-2013, 12:39 PM |  |  
	
		| No Author   Posting Freak
 
 Posts: 962
 Threads: 10
 Joined: Jun 2012
 Reputation: 
13
 | 
			| RE: Locking Doors ,Give Item ,and Lights 
 
				 (01-22-2013, 12:39 PM)BeeKayK Wrote:  void SetLampLit(string& asName, bool abLit, bool abEffects);(Un)lits a lamp.
 asName - Name of the lamp
 abLit - Set true if you want the lamp to be lit, set to false if you want the lamp to be unlit
 abEffects - If you want to have the lamp fade in/out when it gets (un)lit
 
Yeah it all works now. Thanks ! 
By the way, is it possible to unlock the door if I lock it ?
			 
 |  |  
	| 01-22-2013, 12:46 PM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: Locking Doors ,Give Item ,and Lights 
 
				Just use the key again?   
 Trying is the first step to success. |  |  
	| 01-22-2013, 12:48 PM |  |  
	
		| No Author   Posting Freak
 
 Posts: 962
 Threads: 10
 Joined: Jun 2012
 Reputation: 
13
 | 
			| RE: Locking Doors ,Give Item ,and Lights 
 
				 (01-22-2013, 12:48 PM)BeeKayK Wrote:  Just use the key again?  
It doesn't work. Oh yeah, I made the door locked in the level editor    
 |  |  
	| 01-22-2013, 12:57 PM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: Locking Doors ,Give Item ,and Lights 
 
				Weird it should work. Does anything happen to the door? Does the sound play?Does it say "Cannot use item this way"?
 
 Trying is the first step to success. |  |  
	| 01-22-2013, 02:49 PM |  |  |