mrscoomich 
 
 
		
			Member 
			
			
			
 
			
	Posts: 55 
	Threads: 6 
	Joined: Mar 2012
	
 Reputation: 
0
		
	 | 
	
		
			
  
HPS error (level editing) 
			 
			
				 //=========================================== 
// Starter's Script File! 
//=========================================== 
 
//=========================================== 
// This runs when the map first starts 
void OnStart() 
 
{ 
if(ScriptDebugOn()) 
{ 
GiveItemFromFile("lantern", "lantern.ent"); 
SetPlayerLampOil(100.0f); 
for(int i = 0;i < 10;i++) 
{ 
GiveItemFromFile("tinderbox", "tinderbox.ent"); 
} 
} 
} 
//=========================================== 
// This runs when the player enters the map 
void OnEnter() 
{ 
{ 
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); 
}  
void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
SetSwingDoorLocked("door_1", false, true); 
PlaySoundAtEntity("", "unlocked_door", "door_1", 0, false); 
RemoveItem("key_1"); 
} 
 
} 
 
//=========================================== 
// This runs when the player leaves the map 
void OnLeave() 
{ 
} 
 
 
 
 
------------------------------------------------------------------------------------------- 
 
 
 
Everytime I do a test run it says this: 
 
 
FATAL ERROR: Could not load script file 'maps/main/my_map.hps'! 
main (27, 8) : ERR : Expected '(' 
 
 
extra info: 
 
I use n++ and the language is set to c++ 
 
--- 
any way to fix this?
			 
			
			
			
				
(This post was last modified: 03-16-2012, 07:48 PM by mrscoomich.)
 
				
			 
		 |  
	 
 | 
 
	| 03-16-2012, 07:36 PM  | 
	
		
	 | 
 
 
	
		
		Adny 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 1,766 
	Threads: 6 
	Joined: Mar 2012
	
 Reputation: 
173
		
	 | 
	
		
			
RE: HPS error (level editing) 
			 
			
				After looking at it, the only thing I can think of is to take the line: 
" 
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);" 
 
Take it out of the void OnEnter(), and add it to void OnStart()
 
You don't want all of your functions to be inside your onstart or onenter, you want them on their own, outside of it. For example,you have:
 void OnEnter() { 	{  	void your function(blahblah) 	} } 
 But that is wrong ^^^^^^^^ It needs to be outside of it, so more like this: 
 void OnEnter() { } 
 
{ 
void yourfunction() } 
From what limited knowledge I have of C++ and the Amnesia scripts, OnStart() should be used to add your callbacks, and set music lights, and OnEnter() should be used for autosaves, and preloading sounds and particle systems. Functions go anywhere else (except OnLeave)If you're ever in doubt, you can check the .hps files from the actual Amnesia game. 
 Hope that helped. If I haven't made my point clear as I think I have, please P.M. me 
			 
			
			
			
		 |  
	 
 | 
 
	| 03-16-2012, 08:56 PM  | 
	
		
	 | 
 
 
	
		
		mrscoomich 
 
 
		
			Member 
			
			
			
 
			
	Posts: 55 
	Threads: 6 
	Joined: Mar 2012
	
 Reputation: 
0
		
	 | 
	
		
			
RE: HPS error (level editing) 
			 
			
				this is what i've done. I did exactly what you said and even the other option u suggested but it's still not working.  
 
 
 
BTW: 
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); <<<<< 
i think this one is really what's wrong. i have a feeling thats the only error there is and i dont know whether to change it, move it or what :/ 
 
------ 
 
 
//=========================================== 
// Starter's Script File! 
//=========================================== 
 
//=========================================== 
// This runs when the map first starts 
void OnStart() 
 
{ 
if(ScriptDebugOn()) 
{ 
GiveItemFromFile("lantern", "lantern.ent"); 
SetPlayerLampOil(100.0f); 
for(int i = 0;i < 10;i++) 
{ 
GiveItemFromFile("tinderbox", "tinderbox.ent"); 
} 
}  
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); 
} 
 
//=========================================== 
// This runs when the player enters the map 
void OnEnter() 
{ 
{ 
 
}  
void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
SetSwingDoorLocked("door_1", false, true); 
PlaySoundAtEntity("", "unlocked_door", "door_1", 0, false); 
RemoveItem("key_1"); 
} 
 
} 
 
 
//=========================================== 
// This runs when the player leaves the map 
void OnLeave() 
{ 
}
			 
			
			
			
		 |  
	 
 | 
 
	| 03-16-2012, 11:10 PM  | 
	
		
	 | 
 
 
	
		
		Equil 
 
 
		
			Member 
			
			
			
 
			
	Posts: 94 
	Threads: 8 
	Joined: Sep 2010
	
 Reputation: 
0
		
	 | 
	
		
			
RE: HPS error (level editing) 
			 
			
				Try having the "UseKeyOnDoor" function outside of OnEnter. Like this: 
void OnStart() 
 
{ 
if(ScriptDebugOn()) 
{ 
GiveItemFromFile("lantern", "lantern.ent"); 
SetPlayerLampOil(100.0f); 
for(int i = 0;i < 10;i++) 
{ 
GiveItemFromFile("tinderbox", "tinderbox.ent"); 
} 
} 
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); 
} 
 
void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
SetSwingDoorLocked("door_1", false, true); 
PlaySoundAtEntity("", "unlocked_door", "door_1", 0, false); 
RemoveItem("key_1"); 
}
  
			 
			
			
			
		 |  
	 
 | 
 
	| 03-17-2012, 01:59 AM  | 
	
		
	 | 
 
 
	
		
		mrscoomich 
 
 
		
			Member 
			
			
			
 
			
	Posts: 55 
	Threads: 6 
	Joined: Mar 2012
	
 Reputation: 
0
		
	 | 
	
		
			
RE: HPS error (level editing) 
			 
			
				 (03-17-2012, 01:59 AM)Equil Wrote:  Try having the "UseKeyOnDoor" function outside of OnEnter. Like this: 
 
void OnStart() 
 
{ 
if(ScriptDebugOn()) 
{ 
GiveItemFromFile("lantern", "lantern.ent"); 
SetPlayerLampOil(100.0f); 
for(int i = 0;i < 10;i++) 
{ 
GiveItemFromFile("tinderbox", "tinderbox.ent"); 
} 
} 
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); 
} 
 
void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
SetSwingDoorLocked("door_1", false, true); 
PlaySoundAtEntity("", "unlocked_door", "door_1", 0, false); 
RemoveItem("key_1"); 
}
  
I did that just now. (copy and pasted)... this time it didn't crash but the door was left unlocked... ?
			  
			
			
			
		 |  
	 
 | 
 
	| 03-17-2012, 03:18 AM  | 
	
		
	 | 
 
 
	
		
		Equil 
 
 
		
			Member 
			
			
			
 
			
	Posts: 94 
	Threads: 8 
	Joined: Sep 2010
	
 Reputation: 
0
		
	 | 
	
		
			
RE: HPS error (level editing) 
			 
			
				I assume you've ticked "Locked" on the door in the level editor then? If so, try putting  
 
SetSwingDoorLocked("door_1", true, true); 
 
in OnStart() 
			 
			
			
			
		 |  
	 
 | 
 
	| 03-17-2012, 05:10 AM  | 
	
		
	 | 
 
 
	
		
		mrscoomich 
 
 
		
			Member 
			
			
			
 
			
	Posts: 55 
	Threads: 6 
	Joined: Mar 2012
	
 Reputation: 
0
		
	 | 
	
		
			
RE: HPS error (level editing) 
			 
			
				errrmm.. no i didnt :\ I left it unlocked. 
 
EDIT: 
 
 
okay. here, i clicked the checkbox as LOCKED, 
changed it to true 
 
here is my script:  
 
*********************** 
 
void OnStart() 
 
{ 
	 
 
	 
	if(ScriptDebugOn()) 
{ 
GiveItemFromFile("lantern", "lantern.ent"); 
SetPlayerLampOil(100.0f); 
for(int i = 0;i < 10;i++) 
	{ 
GiveItemFromFile("tinderbox", "tinderbox.ent"); 
	} 
	} 
AddUseItemCallback("", "key_1", "mansion_1", "UsedKeyOnDoor", true); 
SetSwingDoorLocked("mansion_1", true, true); 
 
 
} 
 
 
void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
 
{ 
	PlaySoundAtEntity("", "unlocked_door", "mansion_1", 0, false); 
	RemoveItem("key_1"); 
} 
 
*********************** 
NOW the problem is, 
when I try to open the door without the key, it is locked. so thats good. 
 
but when i grab my key, and use it with the door , 
not ONLY does the key disappear but the door does not unlock. it stays closed like it was before ? 
this is my first time scripting and i have spent a week on learning this kind of programming so im sorry about that LOL. 
 
 
JUST wondering if there is something on the HPL2 program that I should write while im on the Entity tab of my mansion_1
			 
			
			
			
				
(This post was last modified: 03-21-2012, 12:33 AM by mrscoomich.)
 
				
			 
		 |  
	 
 | 
 
	| 03-18-2012, 07:04 PM  | 
	
		
	 | 
 
 
	
		
		DaAinGame 
 
 
		
			Member 
			
			
			
 
			
	Posts: 90 
	Threads: 11 
	Joined: Mar 2012
	
 Reputation: 
4
		
	 | 
	
		
			
RE: HPS error (level editing) 
			 
			
				Its because you never tell the door to actually unlock itself.  
 
void OnStart() 
{ 
	if(ScriptDebugOn()) 
{ 
 
GiveItemFromFile("lantern", "lantern.ent"); 
SetPlayerLampOil(100.0f); 
for(int i = 0;i < 10;i++) 
	{ 
GiveItemFromFile("tinderbox", "tinderbox.ent"); 
	} 
	} 
AddUseItemCallback("", "key_1", "mansion_1", "UsedKeyOnDoor", true); 
SetSwingDoorLocked("mansion_1", true, true); 
} 
 
void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
SetSwingDoorLocked("mansion_1", false, true); 
	PlaySoundAtEntity("", "unlocked_door", "mansion_1", 0, false); 
	RemoveItem("key_1"); 
} 
 
The green line is missing, which is why your door never unlocked. Hope it works now! 
			 
			
			
 
			
				
(This post was last modified: 03-21-2012, 04:24 AM by DaAinGame.)
 
				
			 
		 |  
	 
 | 
 
	| 03-21-2012, 04:23 AM  | 
	
		
	 | 
 
 
	
		
		mrscoomich 
 
 
		
			Member 
			
			
			
 
			
	Posts: 55 
	Threads: 6 
	Joined: Mar 2012
	
 Reputation: 
0
		
	 | 
	
		
			
RE: HPS error (level editing) 
			 
			
				It worked! THANKS =D 
.... but one problem.. the sound of the unlocked_door didnt play o.o
			 
			
			
			
		 |  
	 
 | 
 
	| 03-21-2012, 10:16 PM  | 
	
		
	 | 
 
 
	
		
		DaAinGame 
 
 
		
			Member 
			
			
			
 
			
	Posts: 90 
	Threads: 11 
	Joined: Mar 2012
	
 Reputation: 
4
		
	 | 
	
		
			
RE: HPS error (level editing) 
			 
			
				 (03-21-2012, 10:16 PM)mrscoomich Wrote:  It worked! THANKS =D 
.... but one problem.. the sound of the unlocked_door didnt play o.o Use this: 
unlock_door.snt
 
try 
			  
			
			
 
			
		 |  
	 
 | 
 
	| 03-21-2012, 10:20 PM  | 
	
		
	 | 
 
 
	 
 |