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
HoyChampoy Offline
Junior Member

Posts: 43
Threads: 16
Joined: Jun 2012
Reputation: 0
#1
Lever Machine Help

Hey Forum,

I am in need of big help, I am hoping someone can easily guide me. So first, I want the player to solve a lever machine puzzle. The code I want is up 12 down 12. When the player gets this correct I want an elevator, that was unable to be used before, to start working. The machine and the elevator are on the same map. I am not very good with variables and stuff. Will someone be willing to guide me? Thanks!

EDIT:

Heres a more specific looking code (If the number is red that means the lever is pulled in that direction.)

III___III____ V____ I____ II____ IV

I____V_____IV____ V____ II____ II
(This post was last modified: 07-20-2012, 11:13 AM by HoyChampoy.)
07-20-2012, 11:01 AM
Find Reply
Kreekakon Offline
Pick a god and pray!

Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation: 124
#2
RE: Lever Machine Help

Open up "13_machine_room"'s hps file from the original Amnesia. I recall they had a near identical puzzle in there, so you should be able to get a general idea of what to do from in there.
07-20-2012, 11:15 AM
Find Reply
HoyChampoy Offline
Junior Member

Posts: 43
Threads: 16
Joined: Jun 2012
Reputation: 0
#3
RE: Lever Machine Help

(07-20-2012, 11:15 AM)Kreekakon Wrote: Open up "13_machine_room"'s hps file from the original Amnesia. I recall they had a near identical puzzle in there, so you should be able to get a general idea of what to do from in there.
Okay i am almost there, but i just can't get the code I want to work which is up 12 down 12.
07-20-2012, 11:43 AM
Find Reply
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 Reply
HoyChampoy Offline
Junior Member

Posts: 43
Threads: 16
Joined: Jun 2012
Reputation: 0
#5
RE: Lever Machine Help

(07-20-2012, 01:57 PM)Ongka Wrote: 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

Thanks for helping! but when i put the code in, it only activates when i put in up 6 down 7.
07-20-2012, 09:29 PM
Find Reply
HoyChampoy Offline
Junior Member

Posts: 43
Threads: 16
Joined: Jun 2012
Reputation: 0
#6
RE: Lever Machine Help

(07-20-2012, 09:29 PM)HoyChampoy Wrote:
(07-20-2012, 01:57 PM)Ongka Wrote: 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

Thanks for helping! but when i put the code in, it only activates when i put in up 6 down 7.


Nevermind it worked Smile
07-20-2012, 11:15 PM
Find Reply
Ongka Offline
Member

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

Good, what did you change?

[Image: 18694.png]
07-20-2012, 11:16 PM
Find Reply




Users browsing this thread: 1 Guest(s)