Frictional Games Forum (read-only)
What's wrong with this lever? - 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: What's wrong with this lever? (/thread-9034.html)



What's wrong with this lever? - SkuLLfac3 - 07-09-2011

Hey,

I have a problem with my script. But I can't find the mistake. Someone may find it? Huh


Code:
void OnStart()
{


    
SetEntityPlayerInteractCallback("lever_easteregg", "Open_easteregg", true);
}


void Open_easteregg (string &in asEntity)
{
     PlaySoundAtEntity("", "door_large_castle_open.snt", "shelf_easteregg", 1.0 / 2, false);
     SetEntityActive("shelf_easteregg",false);
     SetEntityActive("shelf_easteregg2",true);
}


void OnEnter()
{

}

Thanks Smile


RE: What's wrong with this lever? - Kyle - 07-09-2011

You don't use a SetEntityPlayerInteractCallback, you use this:

Code:
void OnStart()
{
     SetEntityConnectionStateChangeCallback("lever_easteregg", "Open_easteregg");
}
void Open_easteregg(string &in asEntity, int alState)
{
     if (alState == 1)
     {
          PlaySoundAtEntity("", "door_large_castle_open.snt", "shelf_easteregg", 1.0 / 2, false);
          SetEntityActive("shelf_easteregg", false);
          SetEntityActive("shelf_easteregg2", true);
     }
}



RE: What's wrong with this lever? - SkuLLfac3 - 07-09-2011

Hmm but I found another mistake and now it works o.O

The lever in the LevelEditor had the wrong name. Blush I changed it and it worked. But the sound doesen't appear. Is your solution the reason for that?


RE: What's wrong with this lever? - Kyle - 07-09-2011

(07-09-2011, 12:58 AM)SkuLLfac3 Wrote: Hmm but I found another mistake and now it works o.O

The lever in the LevelEditor had the wrong name. Blush I changed it and it worked. But the sound doesen't appear. Is your solution the reason for that?

Nope. It's because you are making a sound appear at an area that doesn't exist (or active).

Since in the same function the location from which the sound is played is unactive, causing it to appear from nowhere, causing it to break itself.

Replace the PlaySoundAtEntity with this:

PlaySoundAtEntity("", "door_large_castle_open.snt", "shelf_easteregg2", 0, false);


If it doesn't work, check the .snt sound and make sure it matches with the one that exists in the sound folder.


RE: What's wrong with this lever? - SkuLLfac3 - 07-09-2011

Yeah the sound file exists.

But I made no soundthingy on the map. Maybe this is the reason?


RE: What's wrong with this lever? - Kyle - 07-09-2011

(07-09-2011, 01:41 AM)SkuLLfac3 Wrote: Yeah the sound file exists.

But I made no soundthingy on the map. Maybe this is the reason?

That is difinately not the reason. You might as well create a ScriptArea near the area in which you want it to play, and then put that in the PlaySoundAtEntity command.


RE: What's wrong with this lever? - SkuLLfac3 - 07-09-2011

Hmm...ok thanks for all Smile