Amnesia editor - Help with scripting // Keys?? - 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 editor - Help with scripting // Keys?? (/thread-19451.html) |
Amnesia editor - Help with scripting // Keys?? - Racingcreed - 12-05-2012 I've recently started to learn the Amnesia editor, but one thing I can not understand at all is scripting keys to work. I've tried watching videos but they don't explain anything, they just show you in a way that only people who know what their doing will understand. I've always tried looking on the wiki for script functions and such, but for someone like myself who has no scripting experience what so ever, it's less than helpful, in fact, it's annoying. I simply want to know what I need to do, step by step, in order to make a key open a certain door. What file do I need to make, how? What do I have to name the key, where do I place files, what script's do I write, where..? Very, very simple explanations would be hugely appreciated because I'm getting annoyed and would like to just focus on continuing learning. Many thanks, RC RE: Amnesia editor - Help with scripting // Keys?? - Rowzter - 12-05-2012 in your maps folder where i think u saved ur map is called maybe "Storage.map", Then there should be a hps file to it. Create a new textfile and name it "Storage.hps" In this hps file you should add this: void OnStart() { AddUseItemCallback("", "NAMEOFKEY", "NAMEOFDOOR", "NAMEOFFUNCTION", true); } void NAMEOFFUNCTION(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "unlock_door", asEntity, 0, false); RemoveItem(asItem); } I hope i wrote it understandable. RE: Amnesia editor - Help with scripting // Keys?? - Racingcreed - 12-05-2012 First of all, thanks for the response. Secondly, a few things I'm unclear off.. In the command list you provided, what would I need to change? I simply want a door to open when a key is used on it, I'm not sure what options I would need to change, and to what to. In addition to this, in my custom story, I have a key, and a door. The door I named to Door01 and set it to locked, the key I've named Key01. Is there any other options on either of these items which would need changing? In the maps folder I have one file, called "Testlevel.hps", and my level name is "Testlevel". Do I still need to create a new file called "Storage.hps" or edit the existing one? I'm sorry I've not familiar with the scripting, I really need it as clear as possible. Many thanks for helping! I really appreciate the help! RE: Amnesia editor - Help with scripting // Keys?? - The chaser - 12-05-2012 (12-05-2012, 08:50 PM)Racingcreed Wrote: First of all, thanks for the response.Well, then: { AddUseItemCallback("", "Key01", "Door01", "FUNCTION", true); } void FUNCTION(string &in asItem, string &in asEntity) { SetSwingDoorLocked("Door01", false, true); PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false); RemoveItem("Key01"); } RE: Amnesia editor - Help with scripting // Keys?? - Racingcreed - 12-05-2012 So like this? http://oi47.tinypic.com/16j0nzp.jpg Is that right? Edit: It works, thanks a lot for the help! So if I wanted to add more keys to the game, I would just copy and paste those commands in the same .hps file, below it and it would work correctly? RE: Amnesia editor - Help with scripting // Keys?? - Rowzter - 12-05-2012 Yep. But i didn't see a void OnStart(). well i worked so whatevah yes you can add more keys but then the other callback func or this: AddUseItemCallback("", "Key01", "Door01", "FUNCTION", true); That should always be in the void OnStart or OnEnter. Like this: void OnEnter { AddUseItemCallback("", "Key01", "Door01", "FUNCTION", true); AddUseItemCallback("", "Key01", "Door01", "FUNCTION", true); AddUseItemCallback("", "Key01", "Door01", "FUNCTION", true); AddUseItemCallback("", "Key01", "Door01", "FUNCTION", true); } But the func should have it own space RE: Amnesia editor - Help with scripting // Keys?? - Racingcreed - 12-05-2012 Can I ask, is this correct? In this example: //////////////////////////// // Run when entering map void OnEnter() { AddUseItemCallback("", "Key01", "Door01", "FUNCTION", true); } void FUNCTION(string &in asItem, string &in asEntity) { SetSwingDoorLocked("Door01", false, true); PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false); RemoveItem("Key01"); } //////////////////////////// // Run when leaving map void OnLeave() { } The adduseitemcallback is the list where you add the functions of a key. So for example, if I wanted to add additional key usages, I would add an additional line with different key names & doors? The void FUNCTION line determines what the word "FUNCTION" does if used in the line with adduseitemcallback? And if I wanted a different result, I would add an addition set of scripts below with links to a different word to give the items a different set of coding meaning? Is that right? I have no idea what the bottom half means :/ RE: Amnesia editor - Help with scripting // Keys?? - The chaser - 12-05-2012 (12-05-2012, 09:09 PM)Racingcreed Wrote: So like this?Yep. Just change the names and it's alright. It's like an alternative language, something like this in real life: void OnAlways() { reaction(); } void reaction () { if (GetLocalVarInt("Dumbass") == 1) //There is a dumbass { SetMoveObjectState("Punch", 1.0f); AddTimer("", 0.5, "Effects"); } void Effects (string &in asTimer) { //Play sound effects, like dumbass screaming, hit, etc } RE: Amnesia editor - Help with scripting // Keys?? - Racingcreed - 12-05-2012 Ok, many thanks for the help! Really appreciate it! |