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 Need help to make a lever puzzle
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#22
RE: Need help to make a lever puzzle

(01-15-2012, 11:56 AM)Your Computer Wrote: Here's a more efficient way of doing it (though entirely untested).

PHP Code: (Select All)
const string[] lever_names = {"LEVER1""LEVER2""LEVER3""LEVER4"}
const 
int[] desired_lever_states = {11, -11}

/******************************************************************************/

void OnStart()
{
    
SetEntityConnectionStateChangeCallback("LEVER1""lever_func");
    
SetEntityConnectionStateChangeCallback("LEVER2""lever_func");
    
SetEntityConnectionStateChangeCallback("LEVER3""lever_func");
    
SetEntityConnectionStateChangeCallback("LEVER4""lever_func");

    
SetLocalVarInt("LEVER1"0);
    
SetLocalVarInt("LEVER2"0);
    
SetLocalVarInt("LEVER3"0);
    
SetLocalVarInt("LEVER4"0);
}

/******************************************************************************/

void lever_func(string &in asEntityint alState)
{
    if (
GetLocalVarInt("LEVER_PUZZLE_COMPLETE") == 1)
        return;

    
SetLocalVarInt(asEntityalState);    
    
CheckFunction();
}

/******************************************************************************/

void CheckFunction()
{
    for (
int i 0lever_names.length(); ++i)
    {
        if (
GetLocalVarInt(lever_names[i]) != desired_lever_states[i])
            return;
        else
        {
            
SetLeverStuckState(lever_names[i], desired_lever_states[i], true);
            
SetEntityConnectionStateChangeCallback(lever_names[i], "");
        }
    }
    
    
GiveSanityBoost();
    
SetSwingDoorLocked("LEVERDOOR"falsetrue);
    
SetLocalVarInt("LEVER_PUZZLE_COMPLETE"1);

Wow that's a lot shorter. I appreciate it, although for now I'm gonna stick with what I understand myself so I have use for it and know what I'm doing.


Thank you very much Tripication.

Current - Castle Darkuan
Other - F*cked Map
(This post was last modified: 01-15-2012, 12:02 PM by Shadowfied.)
01-15-2012, 12:01 PM
Find


Messages In This Thread
Need help to make a lever puzzle - by Shadowfied - 01-14-2012, 11:55 AM
RE: Need help to make a lever puzzle - by Statyk - 01-14-2012, 06:21 PM
RE: Need help to make a lever puzzle - by Statyk - 01-14-2012, 07:39 PM
RE: Need help to make a lever puzzle - by flamez3 - 01-15-2012, 10:54 AM
RE: Need help to make a lever puzzle - by Shadowfied - 01-15-2012, 12:01 PM
RE: Need help to make a lever puzzle - by Statyk - 01-15-2012, 03:13 PM
RE: Need help to make a lever puzzle - by Inurias - 01-16-2012, 09:11 PM



Users browsing this thread: 1 Guest(s)