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
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#25
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);




Goodness gracious great balls of fire, this is ridiculous... XD I have a lot to learn! I might give this a whirl to try it out. Also need to find time to watch your scripting tutorial. And guys, I'm really NOT the best scripter. I'm glad you appreciate the effort and stuff but I'm still a newbie to this stuff. >>; I'm glad you liked Hunter though =P I think I'm going to continue it in Cry's 2nd 24-Hour installment.


Also, instead of setting new levers and whatnot, in the "CheckFunction", add this (all issues solved when you can't touch the levers after completion):

CheckFunction()
{
SetEntityInteractionDisabled("LEVER1", true);
SetEntityInteractionDisabled("LEVER2", true);
SetEntityInteractionDisabled("LEVER3", true);
SetEntityInteractionDisabled("LEVER4", true);
}
(This post was last modified: 01-15-2012, 03:23 PM by Statyk.)
01-15-2012, 03:13 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 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)