![]() |
Keys on Doors... - 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: Keys on Doors... (/thread-19394.html) |
Keys on Doors... - ryan1431 - 12-01-2012 Okay, so I've been working getting a single key on a single door for about half a week now... and its really annoying so i was wondering if some1 could help me. I use HPL with amnesia (windowed) open with debug, so when i make a change on HPL, i save it and go to amnesia and press quick map reload. I tweaked my ".hps" file (void stuff) as i should have to get the key registered and working. This is what i have in that file... void OnStart() { AddUseItemCallback("", "studykey_1", "mansion_2", "OPEN", true); } void OPEN(string &in asItem, string &in asEntity) { SetSwingDoorLocked(mansion_2, false, true); PlaySoundAtEntity("", "unlock_door", mansion_2, 0, false); RemoveItem(studykey_1); } Using this information, which is 100% correct (names n stuff), i get 6 Error reports when i try to quick reload. These are the errors: 1)main (5,1) : INFO : Compiling void OPEN(string&in, string&in) 2)main (8,24) : ERR : 'mansion_2' is not declared 3)main (9,5) : ERR : No matching signatures to 'PlaySoundAtEntity(string@&, string@&, int, const uint, const bool) 4)main (9,5) : INFO : Candidates are: 5)main (9,5) : INFO : void PlaySoundAtEntity(string&in, string&in, string&in, float, bool) 6)main (10,16) : ERR : 'studykey_1' is not declared RE: Keys on Doors... - JMFStorm - 12-01-2012 (12-01-2012, 07:54 AM)ryan1431 Wrote:You don't know how to read? The errors are indicated right here. Just copy paste this over your current so it all probably starts to work: void OnStart() { AddUseItemCallback("", "studykey_1", "mansion_2", "OPEN", true); } void OPEN(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_2", false, true); PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false); RemoveItem("studykey_1"); } RE: Keys on Doors... - GoranGaming - 12-01-2012 void OnStart() { AddUseItemCallback("", "studykey_1", "mansion_2", "OPEN", true); } void OPEN(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_2", false, true); PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false); RemoveItem(studykey_1); } You forgot to declare mansion_2 two times in the OPEN function. RE: Keys on Doors... - ryan1431 - 12-01-2012 (12-01-2012, 08:06 AM)JMFStorm Wrote: TYVM man!!! i'm so relieved!!! i have one more question... RE: Keys on Doors... - TheGreatCthulhu - 12-01-2012 Just for the sake of clarity: he didn't forget to declare mansion_2 - he forgot to put it in quotes, and make it a string literal (that is: "mansion_2" ). The compiler, reaching the token mansion_2 saw that it wasn't in quotes, so it assumed it's a variable, but it couldn't figure out what kind of variable it was, since such a variable was never declared. A declaration is when you introduce a variable to your code, like this: Code: string targetDoor = "mansion_2"; This declares a string variable named targetDoor, which can then be used later on in various places in the code (assuming it's a global var), like this: Code: PlaySoundAtEntity("", "unlock_door", targetDoor, 0, false); |