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
Lever Machine Help
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#4
RE: Lever Machine Help

I've done pretty much the same riddle, just with 8 levers.

Anyway, heres the whole script with 6 levers.
void OnStart()
{
for(int i=1;i<7;i++)
{
SetEntityConnectionStateChangeCallback("lever_"+i, "LeverRiddle");
}
}

void LeverRiddle(string &in asEntity, int alState)
{

    if(alState == 1){
        if(asEntity == "lever_1") SetLocalVarInt("up_"+asEntity, 3);
        else if(asEntity == "lever_2") SetLocalVarInt("up_"+asEntity, 3);
        else if(asEntity == "lever_3") SetLocalVarInt("up_"+asEntity, 5);
        else if(asEntity == "lever_4") SetLocalVarInt("up_"+asEntity, 1);
        else if(asEntity == "lever_5") SetLocalVarInt("up_"+asEntity, 2);
        else if(asEntity == "lever_6") SetLocalVarInt("up_"+asEntity, 4);
        CheckValue(asEntity);
        
        AddDebugMessage("Lever Min & up value: " + GetLocalVarInt("up_value"), false);
    }
    else if(alState == -1){
        if(asEntity == "lever_1") SetLocalVarInt("down_"+asEntity, 1);
        else if(asEntity == "lever_2") SetLocalVarInt("down_"+asEntity, 5);
        else if(asEntity == "lever_3") SetLocalVarInt("down_"+asEntity, 4);
        else if(asEntity == "lever_4") SetLocalVarInt("down_"+asEntity, 5);
        else if(asEntity == "lever_5") SetLocalVarInt("down_"+asEntity, 2);
else if(asEntity == "lever_6") SetLocalVarInt("down_"+asEntity, 2);
        CheckValue(asEntity);
            
        AddDebugMessage("Lever Max & down value: " + GetLocalVarInt("down_value"), false);
    }    
    else if(alState == 0){
        SetLocalVarInt("up_"+asEntity, 0);
        SetLocalVarInt("down_"+asEntity, 0);
                
        AddDebugMessage("Lever Mid", false);
    }
    
    /*All levers correct
     */
    if(GetLocalVarInt("up_value") == 12 && GetLocalVarInt("down_value") == 12)
    {

        for(int i=1;i<7;i++)
        {
            SetLeverStuckState("lever_"+i, GetLeverState("lever_"+i), true);
        }        
    }
}

void CheckValue(string sEntity)
{
    PlaySoundAtEntity("s"+sEntity, "lever_mech_min_max", sEntity, 0.0f, false);
    
    SetLocalVarInt("up_value", 0);
    SetLocalVarInt("down_value", 0);
        
    for(int i=1;i<=6;i++){
        AddLocalVarInt("up_value", GetLocalVarInt("up_lever_"+i));
        AddLocalVarInt("down_value", GetLocalVarInt("down_lever_"+i));
    }
}
There you go! Have fun Wink

[Image: 18694.png]
(This post was last modified: 07-20-2012, 01:58 PM by Ongka.)
07-20-2012, 01:57 PM
Find


Messages In This Thread
Lever Machine Help - by HoyChampoy - 07-20-2012, 11:01 AM
RE: Lever Machine Help - by Kreekakon - 07-20-2012, 11:15 AM
RE: Lever Machine Help - by HoyChampoy - 07-20-2012, 11:43 AM
RE: Lever Machine Help - by Ongka - 07-20-2012, 01:57 PM
RE: Lever Machine Help - by HoyChampoy - 07-20-2012, 09:29 PM
RE: Lever Machine Help - by HoyChampoy - 07-20-2012, 11:15 PM
RE: Lever Machine Help - by Ongka - 07-20-2012, 11:16 PM



Users browsing this thread: 1 Guest(s)