| 
		
	
		| Togglevolt   Junior Member
 
 Posts: 10
 Threads: 2
 Joined: Nov 2011
 Reputation: 
0
 | 
			| Leveldoor Problem 
 
				Hi!
 I want my level door to be locked if you don't have a lantern in your inventory. But for some reason it doesn't work. If I don't have a lantern a message say "I need to find a Lantern". But I still teleports to the next map.
 
 Help!
 
 Here's my script:
 
 
 
 void CheckLantern(string &in asEntity)
 {
 if(HasItem("lantern_1") == true)
 SetLevelDoorLocked(asEntity, false);
 else
 SetLevelDoorLocked(asEntity, true);
 SetMessage("Ch01Level01", "InteractLevelDoor", 0);
 }
 
 
 void OnEnter()
 {
 SetEntityPlayerInteractCallback("level_wood_1", "CheckLantern", true);
 }
 
 
 I have also placed the "CheckLantern" into Entity of the leveldoor, in the PlayerInteractCallback tab.
 |  |  
	| 11-13-2011, 07:27 PM |  |  
	
		| Your Computer   SCAN ME!
 
 Posts: 3,456
 Threads: 32
 Joined: Jul 2011
 Reputation: 
235
 | 
			| RE: Leveldoor Problem 
 
				Try this for your OnEnter function: void OnEnter(){
 CheckLantern("level_wood_1");
 }
 |  |  
	| 11-13-2011, 08:07 PM |  |  
	
		| Togglevolt   Junior Member
 
 Posts: 10
 Threads: 2
 Joined: Nov 2011
 Reputation: 
0
 | 
			| RE: Leveldoor Problem 
 
				It works!
 Only problem is, it shows the message when I start the map too. In the very beginning. "/
 Any idea how to fix that?
 
 I want it displayed only when I touch the door.
 |  |  
	| 11-13-2011, 08:32 PM |  |  
	
		| Your Computer   SCAN ME!
 
 Posts: 3,456
 Threads: 32
 Joined: Jul 2011
 Reputation: 
235
 | 
			| RE: Leveldoor Problem 
 
				 (11-13-2011, 08:32 PM)Togglevolt Wrote:  It works!
 Only problem is, it shows the message when I start the map too. In the very beginning. "/
 Any idea how to fix that?
 
 I want it displayed only when I touch the door.
 
What kind of message are we talking about? If it's a locked message or focus message, then we can avoid using SetMessage. Otherwise, just place the SetMessage in a separate (interact) callback.
			 
 |  |  
	| 11-13-2011, 08:36 PM |  |  
	
		| Togglevolt   Junior Member
 
 Posts: 10
 Threads: 2
 Joined: Nov 2011
 Reputation: 
0
 | 
			| RE: Leveldoor Problem 
 
				The SetMessage("Ch01Level01", "InteractLevelDoor", 0); = Maybe I should find a Lantern first.
 
 It is displayed as wanted when I touch the door without a Lantern. But it is also displayed at the very
 beginning. I have a "wake up" intro, so it makes no sence having a message telling you to find a
 Lantern first when your waking up.
 |  |  
	| 11-13-2011, 08:42 PM |  |  
	
		| Your Computer   SCAN ME!
 
 Posts: 3,456
 Threads: 32
 Joined: Jul 2011
 Reputation: 
235
 | 
			| RE: Leveldoor Problem 
 
				 (11-13-2011, 08:42 PM)Togglevolt Wrote:  The SetMessage("Ch01Level01", "InteractLevelDoor", 0); = Maybe I should find a Lantern first.
 
 It is displayed as wanted when I touch the door without a Lantern. But it is also displayed at the very
 beginning. I have a "wake up" intro, so it makes no sence having a message telling you to find a
 Lantern first when your waking up.
 
In that case we can avoid using the SetMessage function. Since the door would, i presume, be unlocked when picking up a lantern, we can safely have that message be the locked message for the level door. In the level editor specify the category and entry names for the desired level door and remove the SetMessage function from your script. 
			 
 |  |  
	| 11-13-2011, 08:49 PM |  |  
	
		| Togglevolt   Junior Member
 
 Posts: 10
 Threads: 2
 Joined: Nov 2011
 Reputation: 
0
 | 
			| RE: Leveldoor Problem 
 
				It works, but it's not perfect. If I have the lantern in my inventory, I have to touch the door twice.The first time I touch it, nothing happens except "Maybe I should find a Lantern first." is displayed. Then the second time I touch it, I get teleported to the next level and no message is displayed.
 
 
 I suppose it unlocks the first time I click it.
 
 |  |  
	| 11-13-2011, 09:12 PM |  |  
	
		| Your Computer   SCAN ME!
 
 Posts: 3,456
 Threads: 32
 Joined: Jul 2011
 Reputation: 
235
 | 
			| RE: Leveldoor Problem 
 
				You probably have the callback that unlocks the door on the level door. The interact callback should be on the lantern to unlock the level door.
			 
 
				
(This post was last modified: 11-13-2011, 10:30 PM by Your Computer.)
 |  |  
	| 11-13-2011, 10:29 PM |  |  
	
		| Togglevolt   Junior Member
 
 Posts: 10
 Threads: 2
 Joined: Nov 2011
 Reputation: 
0
 | 
			| RE: Leveldoor Problem 
 
				I tried to put the "CheckLantern" in the interact callback tab on the lantern. Then the level door is locked even if I have the lantern on me.
 
 CheckLantern looks like this:
 
 
 
 void CheckLantern(string &in asEntity)
 {
 if(HasItem("lantern_1") == true){
 SetLevelDoorLocked(asEntity, false);
 }
 else{
 SetLevelDoorLocked(asEntity, true);
 }
 
 }
 
 
 void OnEnter()
 {
 
 CheckLantern("level_wood_1");
 }
 |  |  
	| 11-13-2011, 11:03 PM |  |  
	
		| Your Computer   SCAN ME!
 
 Posts: 3,456
 Threads: 32
 Joined: Jul 2011
 Reputation: 
235
 | 
			| RE: Leveldoor Problem 
 
				There is no reason to check if the player has a lantern within the interact callback of the lantern itself.
			 
 |  |  
	| 11-14-2011, 01:20 AM |  |  |