Frictional Games Forum (read-only)
Lever Puzzle Scripting - 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: Lever Puzzle Scripting (/thread-23724.html)



Lever Puzzle Scripting - 3gamers - 10-28-2013

Hey guys, I'm working on my first mod for Amnesia and I've looked up tons of videos to help me with this but none of them tell me everything.

I have one of those four lever puzzle things that I want that when you pull each lever you hear a chick screaming and when you have pulled all of them, the prison door unlocks so you can go to the next level.

I'm new to scripting so can someone please help? I really have no idea what to do. I've already got the sound files and I've tried scripting it myself but nothings worked. Any advice would help.


RE: Lever Puzzle Scripting - PutraenusAlivius - 10-29-2013

Just whipped this out. It's not tested yet so I *think* you'll find some troubles. You have to change some names too.
Spoiler below!

PHP Code:
//Your levers must be Lever_1, Lever_2, and so on until Lever_4.
void OnStart()
{
    
SetEntityConnectionStateChangeCallback("Lever_*""Scream");
    
SetLocalVarInt("Levers"0);
}

void Scream(string &in asEntitystring &in type)
{
    if(
alState = -1)
    {
    
PlaySoundAtEntity("Screams""SoundFile.snt""Player"0.1ffalse);
    
AddLocalVarInt("Levers"1);
    
CheckLevers();
    }
}

void CheckLevers()
{
    if(
GetLocalVarInt("Levers") == 4)
    {
    
SetSwingDoorLocked("DoorName"falsetrue);
    }





RE: Lever Puzzle Scripting - 3gamers - 10-29-2013

Hey, the code definitely worked but the sound syntax I had to use was PlayGuiSound because it was an .ogg file. Thanks a bunch though!

This is what I ended up using:

PlayGuiSound("girlscream3.ogg", 70)


RE: Lever Puzzle Scripting - PutraenusAlivius - 10-29-2013

That works too.

EDIT:
That script is wrong.
It's
PHP Code:
PlayGuiSound("girlscream3.ogg"70.0f