Frictional Games Forum (read-only)

Full Version: Lever Puzzle Scripting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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);
    }


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)
That works too.

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