Frictional Games Forum (read-only)
HPS file not doing anything - 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: HPS file not doing anything (/thread-29808.html)



HPS file not doing anything - SetsuPotato - 04-08-2015

So I started working on a custom story today. I made a key that is supposed to unlock a door but it doesn't. When I try to use the key on the door, it simply says "Cannot use item this way".
I checked through all my code and it seems right to me. I tried the same thing on another map and it didn't work either.

The HPS file:
_________________________________________________________________
void OnEnter()
{
AddUseItemCallback("", "keystair", "doorstair", "UsedKeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("doorstair", false, true);
PlaySoundAtEntity("", "unlock_door", "doorstair", 0, false);
RemoveItem("keystair");
}

void OnLeave()
{

}
_________________________________________________________________

Also, keystair= name of key and doorstair= name of door. I checked to make sure that the objects both have the right name and they do.


RE: HPS file not doing anything - 7heDubz - 04-08-2015

Your function to call is "UsedKeyOnDoor"
[Image: 47bbe5b2dc.png]

However your function name down here is just "KeyOnDoor"
[Image: 3f4e1e37d7.png]

I would also double check the name of the door in your game. It should be the same as you have it here ("doorstair")
[Image: 47bbe5b2dc.png]

I have rewritten your code fixing your issue as well as another you had with your sounds. You have to have the .snt extension.

Please please please! I really want you to look over the code and take a look at your mistakes and rewrite the code yourself. You should use this as a sort of guide, but not a copy-pasta solution.

Code:
void OnEnter()
{
    AddUseItemCallback("", "theKey", "theDoor", "usedKeyOnDoor", true);
}

void usedKeyOnDoor(string, string)
{
    SetSwingDoorLocked("theDoor", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "theDoor", 0, false);
    RemoveItem("theKey");
}



RE: HPS file not doing anything - SetsuPotato - 04-08-2015

(04-08-2015, 03:24 AM)7heDubz Wrote: Your function to call is "UsedKeyOnDoor"
[Image: 47bbe5b2dc.png]

However your function name down here is just "KeyOnDoor"
[Image: 3f4e1e37d7.png]

I would also double check the name of the door in your game. It should be the same as you have it here ("doorstair")
[Image: 47bbe5b2dc.png]

I have rewritten your code fixing your issue as well as another you had with your sounds. You have to have the .snt extension.

Please please please! I really want you to look over the code and take a look at your mistakes and rewrite the code yourself. You should use this as a sort of guide, but not a copy-pasta solution.

Code:
void OnEnter()
{
    AddUseItemCallback("", "theKey", "theDoor", "usedKeyOnDoor", true);
}

void usedKeyOnDoor(string, string)
{
    SetSwingDoorLocked("theDoor", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "theDoor", 0, false);
    RemoveItem("theKey");
}

Sorry, I used a youtube video to do it. He left "usedKeyOnDoor" as "MyFunc" but I changed it to "usedKeyOnDoor" because someone else did it in another video. But I'll try to see if it works.


RE: HPS file not doing anything - FlawlessHappiness - 04-08-2015

Return here if it doesn't! Smile