Frictional Games Forum (read-only)
On, Off Button - 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: On, Off Button (/thread-20867.html)



On, Off Button - User01 - 03-02-2013

I need a little help. When I push the button, the lamp gets on. But when I push it again it will just stay on, insteadt off. What do I need to add/change?

PHP Code:
void OnStart()
{
SetLocalVarInt("Var1"0);
SetEntityPlayerInteractCallback("button1""func1"false);
}


void func1(string &in asEntity)
{
AddLocalVarInt("Var1"1);
    
SetLampLit("bonfire1"truetrue);
    
PlaySoundAtEntity("""spot.snt""bonfire1"0.5ffalse);




RE: On, Off Button - No Author - 03-02-2013

(03-02-2013, 03:57 AM)User01 Wrote: I need a little help. When I push the button, the lamp gets on. But when I push it again it will just stay on, insteadt off. What do I need to add/change?

PHP Code:
void OnStart()
{
SetLocalVarInt("Var1"0);
SetEntityPlayerInteractCallback("button1""func1"false);
}


void func1(string &in asEntity)
{
AddLocalVarInt("Var1"1);
    
SetLampLit("bonfire1"truetrue);
    
PlaySoundAtEntity("""spot.snt""bonfire1"0.5ffalse);


Use this :
PHP Code:
void OnStart()
{
SetEntityPlayerInteractCallback("button1""func1"false);
}


void func1(string &in asEntity)
{
    
SetLampLit("bonfire1"truetrue);
    
PlaySoundAtEntity("""spot.snt""bonfire1"0.5ffalse);
    
SetEntityPlayerInteractCallback("button1""func2"false);
}

void func2(string &in asEntity)
{
    
SetLampLit("bonfire1"falsetrue);
    
PlaySoundAtEntity("""///////YOUR SOUND////////""bonfire1"0.5ffalse);
    
SetEntityPlayerInteractCallback("button1""func1"false);


I changed the script to make it loop(When you press the button, it goes off. When you press it again, it goes on. And so on).


RE: On, Off Button - User01 - 03-02-2013

Thank you Heart


RE: On, Off Button - No Author - 03-02-2013

Your are very welcomeSmile