Frictional Games Forum (read-only)

Full Version: Keys on Doors...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
(12-01-2012, 07:54 AM)ryan1431 Wrote: [ -> ]
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)
6)main (10,16) : ERR : 'studykey_1' is not declared
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");
}
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.
(12-01-2012, 08:06 AM)JMFStorm Wrote: [ -> ]TYVM man!!! i'm so relieved!!! i have one more question...

if i want to keep making more keys and stuff do i just add all the stuff below the other key stuff? or do i have to add new "{ }" 's

(12-01-2012, 07:54 AM)ryan1431 Wrote: [ -> ]
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)
6)main (10,16) : ERR : 'studykey_1' is not declared
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");
}
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);