![]() |
Amnesia Scripting help? - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: Amnesia Scripting help? (/thread-17822.html) |
Amnesia Scripting help? - taylor122002 - 08-17-2012 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. RE: Amnesia Scripting help? - Adny - 08-17-2012 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. RE: Amnesia Scripting help? - onv - 08-18-2012 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 ![]() RE: Amnesia Scripting help? - FlawlessHappiness - 08-18-2012 I guess his key name is Key1. If it was the default name it would be something like key_study_1. ![]() RE: Amnesia Scripting help? - onv - 08-19-2012 (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. RE: Amnesia Scripting help? - FlawlessHappiness - 08-19-2012 Oh yea you're right! ![]() RE: Amnesia Scripting help? - onv - 08-20-2012 Yep , it's only used in the extra_english.lang ![]() RE: Amnesia Scripting help? - taylor122002 - 08-20-2012 Thank you! It worked! ![]() ![]() (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 : |