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

Posts: 41
Threads: 3
Joined: Dec 2011
Reputation: 1
#1
Lever Machine

Sorry I'm asking so many questions if you've noticed me, but I promise when I get everything down I'll give back to the Development Support community.

So I took some ideas from an old thread and came up with this for solving a lever puzzle that is 6 machine levers hanging on a machine (Not regular wall levers)

I put areas above and below them for the entities to collide with and call their corresponding functions.
This is what I have.

(In the OnStart:
    AddEntityCollideCallback("lever_1", "leverup", "lever1", true, 1);
    AddEntityCollideCallback("lever_2", "leverdown", "lever2", true, 1);
    AddEntityCollideCallback("lever_3", "leverdown", "lever3", true, 1);
    AddEntityCollideCallback("lever_4", "leverup", "lever4", true, 1);
    AddEntityCollideCallback("lever_5", "leverdown", "lever5", true, 1);
    AddEntityCollideCallback("lever_6", "leverup", "lever6", true, 1);
}
///Lever Puzzle

void PerformLeverTaskCompleted()
{
SetSwingDoorLocked("door1", false, false);
SetSwingDoorClosed("door1", false, false);
PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
PlaySoundAtEntity("", "quest_completed.snt", "Player", 0.5f, false);
StartEffectFlash(1, 0.4, 1);
}

void lever1 (string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("Levers", 1);
    CheckLevers();
}
void lever2 (string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("Levers", 1);
    CheckLevers();
}
void lever3 (string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("Levers", 1);
    CheckLevers();
}
void lever4 (string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("Levers", 1);
    CheckLevers();
}
void lever5 (string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("Levers", 1);
    CheckLevers();
}
void lever6 (string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("Levers", 1);
    CheckLevers();
}

void CheckLevers()
{
    if (GetLocalVarInt("Levers") == 6)    
    {
    PerformLeverTaskCompleted();
    }
}

Everything works as it should, except for the fact that you don't have to actually have to have the puzzle correct in the end, just have each lever in the correct position at some time because it'll add a value each time a lever is put into a position. So how do I get it to subtract that value if it's moved out of position?
I've tried, but I just get errors each time I try to fix this.

~Thank you
RandomGuy
12-31-2011, 12:44 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#2
RE: Lever Machine

You could just use SetLeverStuckState. This freezes the lever and you cannot move it anymore.




SetLeverStuckState("name of lever", -1,0,1, true);

alState - 0 = not stuck, 1 = at max, -1 = at min 3



If you wanted, couldn't you just put a scriptarea where the lever is and SetLocalVarInt("Levers", -1);
This could cause other problems aswell, such as people detracting over and over that they can't make it add up to a positive value. But then again; it's up to you.

12-31-2011, 01:40 AM
Find
Randomguy9900 Offline
Junior Member

Posts: 41
Threads: 3
Joined: Dec 2011
Reputation: 1
#3
RE: Lever Machine

I don't want the levers to become stuck in any state. That would defeat the purpose.
And I guess I don't quite get what your other point is, sorry.

EDIT: I guess I get what you're saying, but the problem would be what you;re stating, you may never get it to be a positive value.
(This post was last modified: 12-31-2011, 01:47 AM by Randomguy9900.)
12-31-2011, 01:43 AM
Find




Users browsing this thread: 1 Guest(s)