Frictional Games Forum (read-only)
Lever and Entity - 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 and Entity (/thread-21432.html)



Lever and Entity - Smackdown - 05-07-2013

Hello

I want that when I turn a lever, there appear and disappear some Entities I want, I also want to add a sound. So it should look like that?

void OnStart()
{
??????("mechanismus2", "lever2", "????", true, false, 0);
}




void func2(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
lever2();
}

void lever2()
{
if(GetLocalVarInt("Var1") == 1)

{
PlaySoundAtEntity("", "explosion_rock_large.snt", "player", 0.5f, false);
GiveSanityBoostSmall();
SetEntityActive("wine02_1", true);

}
}



Or how do I script that? I don't get it. Please help


RE: Lever and Entity - Tomato Cat - 05-07-2013

So...You want to pull a lever and have an entity appear/disappear?

You have it mostly right. You don't really need the variable, though.

For example, this should be a SetEntityConnectionStateChangeCallback

PHP Code:
void OnStart()
{
??????(
"mechanismus2""lever2""????"truefalse0);
}

//Include this in your OnStart 
SetEntityConnectionStateChangeCallback("name of your lever""the function to call"); 

The callback function's syntax would look like this:

PHP Code:
void YourFunction(string &in asEntityint alState)
{
  
//This checks what "state" the lever is in
  
if(alState == 1//1 is on, 0 is in between and -1 means off
  
{
     
//Do what you want to happen here
  
}





RE: Lever and Entity - Smackdown - 05-07-2013

Thank you very much.
All things work, except the sound. It does not play the explosion thing on player:

PHP Code:
void explosion(string &in asEntityint alState)
{
  
//This checks what "state" the lever is in
  
if(alState == 1//1 is on, 0 is in between and -1 means off
  
{
        
PlaySoundAtEntity("""""player"0.5ffalse);
 
PlaySoundAtEntity("""explosion_rock_large.snt""player"0false);
    
GiveSanityBoostSmall();
    
SetEntityActive("wood_beam_2"false);
    
SetEntityActive("wood_beam_3"false);
    
SetEntityActive("wood_beam_4"false);
    
SetEntityActive("rock_debris_brown02_*"false);
    
SetEntityActive("stone_med01_brown_8"false);
    
SetEntityActive("stone_med01_brown_9"false);
    
SetEntityActive("stone_med01_brown_10"false);
    
SetEntityActive("stone_med01_brown_11"false);

  }





RE: Lever and Entity - Tomato Cat - 05-07-2013

I'm not sure if it matters, but try capitalizing "player."


RE: Lever and Entity - DnALANGE - 05-07-2013

player must be Player.
try that and remove the other line, it is useless there : PlaySoundAtEntity("", "", "player", 0.5f, false);


RE: Lever and Entity - Smackdown - 05-07-2013

Ill try

How do I delet posts? ^^


Thank you, that was the fault. Now it works with Player Wink