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
Script Help Lever Puzzle Help
RurouniMori Offline
Junior Member

Posts: 11
Threads: 3
Joined: Apr 2013
Reputation: 0
#6
RE: Lever Puzzle Help

(05-10-2013, 12:27 AM)Tomato Cat Wrote: Ok, try this out.

Basically what's happening is that a variable is incremented each time you pull a lever, which is locked in place. (But if it's the correct lever, a separate variable is incremented.) This repeats until all 3 levers are pulled and function checks to see if the levers were pulled in the correct order.

Add these to OnStart, first:
PHP Code: (Select All)
SetLocalVarInt("Lever",0);
SetLocalVarInt("Correct",0);
SetEntityConnectionStateChangeCallback("lever_nice01_*""LeverCallback"); 

Here's the main function:
Spoiler below!

PHP Code: (Select All)
void LeverCallback(string &in asEntityint alState)
        {    
            
AddDebugMessage("Lever "+asEntity " "+alState,false);
            
            if(
alState == 1)
            {
            
                if(
GetLocalVarInt("Lever") == 0)
                {
                    if(
asEntity == "lever_nice01_1")
                    {
                        
SetLeverStuckState(asEntity1true);
                        
AddLocalVarInt("Lever",1);
                        
AddDebugMessage(asEntity,false);
                    }
                    
                    else if(
asEntity == "lever_nice01_2")
                    {
                        
AddLocalVarInt("Correct",1);
                        
AddDebugMessage(asEntity,false);
                        
SetLeverStuckState(asEntity1true);
                        
AddLocalVarInt("Lever",1);
                    }
                    
                    else if(
asEntity == "lever_nice01_3")
                    {
                        
SetLeverStuckState(asEntity1true);
                        
AddLocalVarInt("Lever",1);
                        
AddDebugMessage(asEntity,false);
                    }    
                }
                
                else if(
GetLocalVarInt("Lever") == 1)
                {
                    if(
asEntity == "lever_nice01_1")
                    {
                        
SetLeverStuckState(asEntity1true);
                        
AddLocalVarInt("Lever",1);
                        
AddDebugMessage(asEntity,false);
                    }
                    
                    else if(
asEntity == "lever_nice01_2")
                    {
                        
AddDebugMessage(asEntity,false);
                        
SetLeverStuckState(asEntity1true);
                        
AddLocalVarInt("Lever",1);
                    }
                    
                    else if(
asEntity == "lever_nice01_3")
                    {
                        
SetLeverStuckState(asEntity1true);
                        
AddLocalVarInt("Lever",1);
                        
AddDebugMessage(asEntity,false);
                        
AddLocalVarInt("Correct",1);
                    }    
                } 

And a continuation...
PHP Code: (Select All)
                else if(GetLocalVarInt("Lever") == 2)
                {
                    if(
asEntity == "lever_nice01_1")
                    {
                        
SetLeverStuckState(asEntity1true);
                        
                        
AddDebugMessage(asEntity,false);
                        
AddLocalVarInt("Correct",1);
                        
CheckLever();
                    }
                    
                    else if(
asEntity == "lever_nice01_2")
                    {
                        
AddDebugMessage(asEntity,false);
                        
SetLeverStuckState(asEntity1true);
                
                        
CheckLever();
                    }
                    
                    else if(
asEntity == "lever_nice01_3")
                    {
                        
SetLeverStuckState(asEntity1true);
                        
                        
AddDebugMessage(asEntity,false);
                        
CheckLever();
                    }    
                }
            }
        } 


This is the function that checks the order:

Spoiler below!
PHP Code: (Select All)
void CheckLever()
{
    if(
GetLocalVarInt("Correct") == 3)
    {
        
AddDebugMessage("Correct order. Good job!",false);
    }
    
    else
    {
        
AddDebugMessage("Incorrect order!",false);
        
SetLeverStuckState("lever_nice01_1",0,true);
        
SetLeverStuckState("lever_nice01_2",0,true);
        
SetLeverStuckState("lever_nice01_3",0,true);
        
SetLocalVarInt("Correct",0);
        
SetLocalVarInt("Lever",0);
    }



Wow thanks! I'll try this out and get back to you! XD
05-10-2013, 01:37 AM
Find


Messages In This Thread
Lever Puzzle Help - by RurouniMori - 05-09-2013, 10:05 PM
RE: Lever Puzzle Help - by Tomato Cat - 05-09-2013, 11:08 PM
RE: Lever Puzzle Help - by RurouniMori - 05-09-2013, 11:22 PM
RE: Lever Puzzle Help - by PutraenusAlivius - 05-10-2013, 12:10 AM
RE: Lever Puzzle Help - by Tomato Cat - 05-10-2013, 12:27 AM
RE: Lever Puzzle Help - by RurouniMori - 05-10-2013, 01:37 AM
RE: Lever Puzzle Help - by RurouniMori - 05-10-2013, 02:46 AM
RE: Lever Puzzle Help - by Tomato Cat - 05-10-2013, 02:59 AM
RE: Lever Puzzle Help - by RurouniMori - 05-10-2013, 03:07 AM
RE: Lever Puzzle Help - by Tomato Cat - 05-10-2013, 03:20 AM



Users browsing this thread: 1 Guest(s)