Karai16 
 
 
		
			Member 
			
			
			
 
			
	Posts: 164 
	Threads: 24 
	Joined: Apr 2011
	
 Reputation: 
0
		
	 | 
	
		
			
I'm back, with a new custom story and another question! [SOLVED] 
			 
			
				Hey guys! I'm back after some time of not being here! ^^ 
I'm working on another custom story at the moment, but I'm facing some problems. You see:
 void OnStart() 
{ 
    SetEntityPlayerInteractCallback("OutsideDoor", "Checking", true); 
    AddEntityCollideCallback("Player", "ScriptArea_1", "Checking2", true, 1); 
} 
 
void Checking(string &in asEntity) 
{ 
    if (HasItem("Lantern")!=true) 
    { 
        SetMessage("Message", "OutsideDoorText", 0); 
    } 
} 
 
void Checking2(string &in asParent , string &in asChild , int alState) 
{ 
    if (HasItem("Lantern")==true) 
    { 
            SetLevelDoorLocked("OutsideDoor", false); 
    } 
}
 This is the code of the Hallway. You can't go through a certain door as long as you don't have your lantern, which is in the bedroom. The lantern's called "Lantern". I've tested it, also with it just trying to play music instead of opening the door, but for some reason, it keeps saying that the second if statement is false, even if you have the lantern... can you help me out? I'm at a loss
  
			 
			
			
 
Custom stories: 
Her Games (100% Complete) 
Her Games, All Bugs Fixed (100% Complete) 
 
			
				
(This post was last modified: 07-27-2011, 04:16 PM by Karai16.)
 
				
			 
		 |  
	 
 | 
 
	| 07-25-2011, 05:08 PM  | 
	
		
	 | 
 
 
	
		
		Tanshaydar 
 
 
		
			From Beyond 
			
			
			
 
			
	Posts: 3,085 
	Threads: 17 
	Joined: Mar 2009
	
 Reputation: 
67
		
	 | 
	
		
			
RE: I'm back, with a new custom story and another question! 
			 
			
				HasItem("Lantern") == true 
 
== true is unneeded here, as HasItem function is a boolean function. 
 
This happened to someone else too. So, how about unlocking the level door on lantern pickup instead of checking if player has it?
			 
			
			
 
			
		 |  
	 
 | 
 
	| 07-25-2011, 06:38 PM  | 
	
		
	 | 
 
 
	
		
		Karai16 
 
 
		
			Member 
			
			
			
 
			
	Posts: 164 
	Threads: 24 
	Joined: Apr 2011
	
 Reputation: 
0
		
	 | 
	
		
			
RE: I'm back, with a new custom story and another question! 
			 
			
				 (07-25-2011, 06:38 PM)Tanshaydar Wrote:  HasItem("Lantern") == true 
 
== true is unneeded here, as HasItem function is a boolean function. 
 
This happened to someone else too. So, how about unlocking the level door on lantern pickup instead of checking if player has it? 
Well you see, lantern is picked up in another map, So that's why I can't unlock that door yet. But if there is a way, I'm all ears ofcourse.
			  
			
			
 
Custom stories: 
Her Games (100% Complete) 
Her Games, All Bugs Fixed (100% Complete) 
 
			
		 |  
	 
 | 
 
	| 07-25-2011, 11:04 PM  | 
	
		
	 | 
 
 
	
		
		DRedshot 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 374 
	Threads: 23 
	Joined: Jun 2011
	
 Reputation: 
11
		
	 | 
	
		
			
RE: I'm back, with a new custom story and another question! 
			 
			
				I found a workaround when i ran into this problem 
if(HasItem("Lantern")){} 
else{ 
// Unlock door 
}
  
			 
			
			
 
			
		 |  
	 
 | 
 
	| 07-25-2011, 11:11 PM  | 
	
		
	 | 
 
 
	
		
		Karai16 
 
 
		
			Member 
			
			
			
 
			
	Posts: 164 
	Threads: 24 
	Joined: Apr 2011
	
 Reputation: 
0
		
	 | 
	
		
			
RE: I'm back, with a new custom story and another question! 
			 
			
				 (07-25-2011, 11:11 PM)DRedshot Wrote:  I found a workaround when i ran into this problem 
 
if(HasItem("Lantern")){} 
else{ 
// Unlock door 
} 
 
  
Well the thing is, the door has to unlock when you  do have the lantern. Also, I've tried something simular before, but it doesn't work either.
			  
			
			
 
Custom stories: 
Her Games (100% Complete) 
Her Games, All Bugs Fixed (100% Complete) 
 
			
		 |  
	 
 | 
 
	| 07-25-2011, 11:32 PM  | 
	
		
	 | 
 
 
	
		
		DRedshot 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 374 
	Threads: 23 
	Joined: Jun 2011
	
 Reputation: 
11
		
	 | 
	
		
			
RE: I'm back, with a new custom story and another question! 
			 
			
				ok, I dont fully understand what you're trying to do. If you want the door to unlock when you do have the lantern, this should work: 
 
if(HasItem("Lantern")){ 
// Unlock Door 
} 
 
if that doesn't work, you may not have called it Lantern.
			 
			
			
 
			
		 |  
	 
 | 
 
	| 07-25-2011, 11:49 PM  | 
	
		
	 | 
 
 
	
		
		Roenlond 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 331 
	Threads: 3 
	Joined: Apr 2011
	
 Reputation: 
0
		
	 | 
	
		
			
RE: I'm back, with a new custom story and another question! 
			 
			
				When you pick up the lantern in map 1, set a global variable to 1 and check if that variable is 1 when you click on the door.
			 
			
			
			
		 |  
	 
 | 
 
	| 07-25-2011, 11:51 PM  | 
	
		
	 | 
 
 
	
		
		Karai16 
 
 
		
			Member 
			
			
			
 
			
	Posts: 164 
	Threads: 24 
	Joined: Apr 2011
	
 Reputation: 
0
		
	 | 
	
		
			
RE: I'm back, with a new custom story and another question! 
			 
			
				 (07-25-2011, 11:51 PM)Roenlond Wrote:  When you pick up the lantern in map 1, set a global variable to 1 and check if that variable is 1 when you click on the door. 
Okay, I did that, but it still won't open the door... Here are the scripts:
 Hallway: (The map where the game starts (atm) and where the door is that needs to be unlocked)
 void OnGameStart() 
{ 
    SetGlobalVarInt("LanternVar", 1); 
} 
 
void OnStart() 
{ 
    SetEntityPlayerInteractCallback("OutsideDoor", "Checking", true); 
    AddEntityCollideCallback("Player", "ScriptArea_1", "Checking2", true, 1); 
} 
 
void Checking(string &in asEntity) 
{ 
    if (GetGlobalVarInt("LanternVar") != 2) 
    { 
        SetMessage("Message", "OutsideDoorText", 0); 
    } 
} 
 
void Checking2(string &in asParent , string &in asChild , int alState) 
{ 
    if (GetGlobalVarInt("LanternVar") == 2) 
    { 
            SetLevelDoorLocked("OutsideDoor", false); 
    } 
}
  
Bedroom: (The map where you get the lantern)
 void OnStart() 
{ 
    SetEntityPlayerInteractCallback("Lantern", "Setvar", true); 
} 
 
void Setvar(string &in asEntity) 
{ 
    AddGlobalVarInt("LanternVar", 1); 
}
 and for the record, yes, I am sure I called the lantern "Lantern"... I tried, but the door still won't open.   
			 
			
			
 
Custom stories: 
Her Games (100% Complete) 
Her Games, All Bugs Fixed (100% Complete) 
 
			
		 |  
	 
 | 
 
	| 07-26-2011, 10:15 PM  | 
	
		
	 | 
 
 
	
		
		Anxt 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 588 
	Threads: 12 
	Joined: Mar 2011
	
 Reputation: 
10
		
	 | 
	
		
			
RE: I'm back, with a new custom story and another question! 
			 
			
				Ok, here's what you do: 
Since you already have your GlobalVarInt set up, use an if statement in your hallway map to unlock the door.  So, for example:
 
void OnEnter() 
{ 
   if(GetGlobalVarInt("LanternVar")==1) 
        {  SetLevelDoorLocked(blahblahblah); 
        } 
}
 
Here's where I suspect the problem is:  You have your LanternVar set to 1 at the start of the game.  Set it to 0.  Then, when you get the lantern, adding 1 to it will make it 1, thus making the function I have outlined for you above work properly.  Hope that helped   
			 
			
			
 
			
		 |  
	 
 | 
 
	| 07-27-2011, 01:06 AM  | 
	
		
	 | 
 
 
	
		
		Karai16 
 
 
		
			Member 
			
			
			
 
			
	Posts: 164 
	Threads: 24 
	Joined: Apr 2011
	
 Reputation: 
0
		
	 | 
	
		
			
RE: I'm back, with a new custom story and another question! 
			 
			
				 (07-27-2011, 01:06 AM)Anxt Wrote:  Ok, here's what you do: 
 
Since you already have your GlobalVarInt set up, use an if statement in your hallway map to unlock the door.  So, for example: 
 
void OnEnter() 
{ 
   if(GetGlobalVarInt("LanternVar")==1) 
        {  SetLevelDoorLocked(blahblahblah); 
        } 
} 
 
Here's where I suspect the problem is:  You have your LanternVar set to 1 at the start of the game.  Set it to 0.  Then, when you get the lantern, adding 1 to it will make it 1, thus making the function I have outlined for you above work properly.  Hope that helped   
Thanks anxt! It's working completely fine now   
			 
			
			
 
Custom stories: 
Her Games (100% Complete) 
Her Games, All Bugs Fixed (100% Complete) 
 
			
		 |  
	 
 | 
 
	| 07-27-2011, 04:15 PM  | 
	
		
	 | 
 
 
	 
 |