| 
		
	
		| taylor122002   Junior Member
 
 Posts: 13
 Threads: 10
 Joined: Aug 2012
 Reputation: 
0
 | 
			| Amnesia Scripting help? 
 
				Hello everybody! I have a question about Scripting. I actually started doing this less than a week ago, so I know nothing. Anyways, I am making little maps for me learn the basics of Scripting. My first map was called "ScriptTest" which was learning how to do Journal Entries, which I managed to learn. Now, I made a map called "ScriptTest2", and I'm using this map to figure out how to unlock doors. And I'm stuck. I was wondering if anybody could look at these functions and see if they're correct or if I did something wrong? I got the key name and description down correctly. But the unlocking the door part..?
 The key's CustomSubItemTypeName is "Key1" and the actual name is just "Key_1", and the door's name is "LockedDoor1"
 
 extra_english.lang file:
 
 <LANGUAGE>
 <CATEGORY Name="CustomStoryMain">
 <Entry Name="Description">Just a description.</Entry>
 </CATEGORY>
 
 <CATEGORY Name="Journal">
 <Entry Name="Note_Test01_Name">Mysterious Note</Entry>
 <Entry Name="Note_Test01_Text">How did you get here, you're probably wondering. You will never escape.</Entry>
 </CATEGORY>
 
 <CATEGORY Name="Inventory">
 <Entry Name="ItemDesc_Key1">A simple key</Entry>
 <Entry Name="ItemName_Key1">A key to unlock a nearby door</Entry>
 </CATEGORY>
 
 </LANGUAGE>
 
 ------------------------------------------
 ScriptTest2.hps file:
 
 ////////////////////////////
 // Run when the map starts
 void OnStart()
 {
 AddUseItemCallback("", "Key1", "LockedDoor1", "UsedKeyOnDoor", true);
 }
 
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("LockedDoor1", false, true);
 PlaySoundAtEntity("", "unlock_door", "LockedDoor1", 0, false);
 RemoveItem("Key1");
 }
 
 
 ////////////////////////////
 // Run when entering map
 void OnEnter()
 {
 
 }
 
 ////////////////////////////
 // Run when leaving map
 void OnLeave()
 {
 
 }
 ---------------------------
 
 Whenever I test play it, it says that I can't use the item on anything when I go up to the door.
 |  |  
	| 08-17-2012, 01:50 AM |  |  
	
		| Adny   Posting Freak
 
 Posts: 1,766
 Threads: 6
 Joined: Mar 2012
 Reputation: 
173
 | 
			| RE: Amnesia Scripting help? 
 
				Both the .hps and .lang files are fine, no mistakes. I have 2 ideas as to what is causing this problem for you:
 1. You map and hps files are not located in the same folder, they do not have the same exact name as each other, or your .hps wasn't converted properly into a c++ script file and is still a text (.txt) file.
 
 2. The names in your script are not the same as the names of the item/entity (key/door) in the level editor. For future reference, you have a much smaller chance of misspelling something if you copy/paste directly from the editor into your hps file.
 
 Hope that helped.
 
 I rate it 3 memes. |  |  
	| 08-17-2012, 04:08 AM |  |  
	
		| onv   Member
 
 Posts: 51
 Threads: 12
 Joined: Feb 2012
 Reputation: 
2
 | 
			| RE: Amnesia Scripting help? 
 
				There is a mistake in your .hps file , you're using the CustomSubItemTypeName instead of the key's name in your script , try this : 
////////////////////////////
 
// Run when the map starts 
void OnStart()
 
{ 
AddUseItemCallback("", "Key_1 ", "LockedDoor1", "UsedKeyOnDoor", true); 
}
 
void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
SetSwingDoorLocked("LockedDoor1", false, true); 
PlaySoundAtEntity("", "unlock_door", "LockedDoor1", 0, false); 
RemoveItem("Key_1 "); 
}
 
////////////////////////////
 
// Run when entering map
 
void OnEnter() 
{
 
}
 
////////////////////////////
 
// Run when leaving map
 
void OnLeave() 
{
 
}
 
I would really appreciate +rep if it worked   
				
(This post was last modified: 08-18-2012, 06:23 PM by onv.)
 |  |  
	| 08-18-2012, 06:20 PM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: Amnesia Scripting help? 
 
				I guess his key name is Key1. If it was the default name it would be something like key_study_1.   
 Trying is the first step to success. |  |  
	| 08-18-2012, 06:30 PM |  |  
	
		| onv   Member
 
 Posts: 51
 Threads: 12
 Joined: Feb 2012
 Reputation: 
2
 | 
			| RE: Amnesia Scripting help? 
 
				 (08-18-2012, 06:30 PM)beecake Wrote:  I guess his key name is Key1. If it was the default name it would be something like key_study_1.  He clearly said that the CustomSubItemTypeName of the key is Key1 , and the name of the key is Key_1 , his script wasn't working because his puted the CustomSubItemName instead of th actula key name.
			 |  |  
	| 08-19-2012, 11:17 AM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: Amnesia Scripting help? 
 
				Oh yea you're right!    I guess the CustomSubItemName is only used in the .lang?
			
 Trying is the first step to success. |  |  
	| 08-19-2012, 01:28 PM |  |  
	
		| onv   Member
 
 Posts: 51
 Threads: 12
 Joined: Feb 2012
 Reputation: 
2
 | 
			| RE: Amnesia Scripting help? 
 
				Yep , it's only used in the extra_english.lang    |  |  
	| 08-20-2012, 03:17 PM |  |  
	
		| taylor122002   Junior Member
 
 Posts: 13
 Threads: 10
 Joined: Aug 2012
 Reputation: 
0
 | 
			| RE: Amnesia Scripting help? 
 
				Thank you! It worked!    I did the Rep+1 thing, as for everyone else, I also thank you for the help!    It's much appreciated!   (08-18-2012, 06:20 PM)onv Wrote:  There is a mistake in your .hps file , you're using the CustomSubItemTypeName instead of the key's name in your script , try this :
 
 
 ////////////////////////////
 
 // Run when the map starts
 void OnStart()
 
 {
 AddUseItemCallback("", "Key_1", "LockedDoor1", "UsedKeyOnDoor", true);
 }
 
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("LockedDoor1", false, true);
 PlaySoundAtEntity("", "unlock_door", "LockedDoor1", 0, false);
 RemoveItem("Key_1");
 }
 
 ////////////////////////////
 
 // Run when entering map
 
 void OnEnter()
 {
 
 }
 
 ////////////////////////////
 
 // Run when leaving map
 
 void OnLeave()
 {
 
 }
 
 I would really appreciate +rep if it worked
  |  |  
	| 08-20-2012, 10:06 PM |  |  |