Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sequence of buttons
xxxxxxxxxxxxxxxx Away
Posting Freak

Posts: 935
Threads: 0
Joined: Jun 2012
Reputation: 54
#2
RE: Sequence of buttons

Hm... I can't script at all, but I'd sure love to learn it, so please forgive me for staining this thread with my curious noobliness. (Also I never know when to shut up) Big Grin
So this would be my theory:

I'm assuming the correct sequence is simply 1234. Pressing button 1 will set the "sequence" variable to 1, pressing 2 will set it to 2 - but only if it was already "1" when you pressed 2 of course. Same principle applies to the buttons 3 and 4 respectively. Pressing 4 while "sequence" is 3 will also open the safe and deactivate the whole button business.

In any case, pressing a button will always increase "buttoncount" by 1. If it reaches 4, "sequence" and "buttoncount" will be set back to 0 and a "try again" message will appear. (This ensures that you have only four "tries" before sequence is resetted, so you have to enter the whole correct sequence in one go and can't just keep pressing buttons.)

I think I may have found the most complicated way to do it...but it might work.
Anyway, here's my sad and crippled attempt at a script that does this. For the love of everything holy, don't copy any of this, it will most likely do something horrible. Wink
void OnStart()
{
SetEntityPlayerInteractCallback("Button_1" , "Button_1_Call" , false);
SetEntityPlayerInteractCallback("Button_2" , "Button_2_Call" , false);
SetEntityPlayerInteractCallback("Button_3" , "Button_3_Call" , false);
SetEntityPlayerInteractCallback("Button_4" , "Button_4_Call" , false);
SetEntityPlayerInteractCallback("Button_5" , "Button_5_Call" , false);
SetEntityPlayerInteractCallback("Button_6" , "Button_6_Call" , false);

void SetLocalVarInt("buttoncount", 0);
void SetLocalVarInt("sequence", 0);
}


void Button_1_Call(string &in asParent, string &in asChild, int alState)
{
    if (GetLocalVarInt("sequence") == 0)
    {
    SetLocalVarInt("sequence", 1);
    }

    AddLocalVarInt("buttoncount", 1);

    if (GetLocalVarInt("buttoncount") == 4)
    {
    SetLocalVarInt("buttoncount", 0);
    SetLocalVarInt("sequence", 0);
    SetMessage("Messages", "tryagain", 0);
    }

}


void Button_2_Call(string &in asParent, string &in asChild, int alState)
{
    if (GetLocalVarInt("sequence") == 1)
    {
    SetLocalVarInt("sequence", 2);
    }

    AddLocalVarInt("buttoncount", 1);

    if (GetLocalVarInt("buttoncount") == 4)
    {
    SetLocalVarInt("buttoncount", 0);
    SetLocalVarInt("sequence", 0);
    SetMessage("Messages", "tryagain", 0);
    }
}


void Button_3_Call(string &in asParent, string &in asChild, int alState)
{
    if (GetLocalVarInt("sequence") == 2)
    {
    SetLocalVarInt("sequence", 3);
    }

    AddLocalVarInt("buttoncount", 1);
    
    if (GetLocalVarInt("buttoncount") == 4)
    {
    SetLocalVarInt("buttoncount", 0);
    SetLocalVarInt("sequence", 0);
    SetMessage("Messages", "tryagain", 0);
    }
}


void Button_4_Call(string &in asParent, string &in asChild, int alState)
{
    if (GetLocalVarInt("sequence") == 3)
    {
    OPEN SAFE;
    DEACTIVATE BUTTONS;
    }

    else
    {
    AddLocalVarInt("buttoncount", 1);
    }

    if (GetLocalVarInt("buttoncount") == 4)
    {
    SetLocalVarInt("buttoncount", 0);
    SetLocalVarInt("sequence", 0);
    SetMessage("Messages", "tryagain", 0);
    }
}


void Button_5_Call(string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("buttoncount", 1);

    if (GetLocalVarInt("buttoncount") == 4)
    {
    SetLocalVarInt("buttoncount", 0);
    SetLocalVarInt("sequence", 0);
    SetMessage("Messages", "tryagain", 0);
    }
}


void Button_6_Call(string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("buttoncount", 1);
    
    if (GetLocalVarInt("buttoncount") == 4)
    {
    SetLocalVarInt("buttoncount", 0);
    SetLocalVarInt("sequence", 0);
    SetMessage("Messages", "tryagain", 0);
    }
}
12-10-2012, 12:53 AM
Find


Messages In This Thread
Sequence of buttons - by ElectricRed - 12-09-2012, 10:19 PM
RE: Sequence of buttons - by xxxxxxxxxxxxxxxx - 12-10-2012, 12:53 AM
RE: Sequence of buttons - by ElectricRed - 12-10-2012, 03:47 AM
RE: Sequence of buttons - by Acies - 12-10-2012, 01:08 AM
RE: Sequence of buttons - by xxxxxxxxxxxxxxxx - 12-10-2012, 11:32 AM



Users browsing this thread: 1 Guest(s)