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
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#18
RE: Need help to make a lever puzzle

Try Duplicating the levers and deactivating the duplicates, turn the InteractionDisablesStuck off on the Inactive duplicates and do this


void OnStart()
{
SetEntityConnectionStateChangeCallback("LEVER1", "lever1func"); //levercallback
SetEntityConnectionStateChangeCallback("LEVER2", "lever2func"); //levercallback
SetEntityConnectionStateChangeCallback("LEVER3", "lever3func"); //levercallback
SetEntityConnectionStateChangeCallback("LEVER4", "lever4func"); //levercallback

SetLocalVarInt("lever1bank", 0); //'dem banks!
SetLocalVarInt("lever2bank", 0); //'dem banks!
SetLocalVarInt("lever3bank", 0); //'dem banks!
SetLocalVarInt("lever4bank", 0); //'dem banks!
}


/////////////////////////////////////////////////////////


void lever1func(string &in asEntity, int alState)
{
if(alState == 1)
{
SetLeverStuckState("LEVER1", 1, true); //sets it stuck
SetLocalVarInt("lever1bank", 1); //add dat cash munay
CheckFunction(); //follows function at the bottom, which activates the completed puzzle
}
if(alState == -1)
{
SetLeverStuckState("LEVER1", -1, true);
SetLocalVarInt("lever1bank", 0);
}
}

//////////////////////////////////////////////////////////////////////

void lever2func(string &in asEntity, int alState)
{
if(alState == 1)
{
SetLeverStuckState("LEVER2", 1, true);
SetLocalVarInt("lever2bank", 1);
CheckFunction();
}
if(alState == -1)
{
SetLeverStuckState("LEVER2", -1, true);
SetLocalVarInt("lever2bank", 0);
}
}

//////////////////////////////////////////////////////////////////////

void lever3func(string &in asEntity, int alState) //follows a different "if" statement, making it opposite from the rest or... Down rather than Up.
{
if(alState == 1)
{
SetLeverStuckState("LEVER3", 1, true);
SetLocalVarInt("lever3bank", 0);
}
if(alState == -1)
{
SetLeverStuckState("LEVER3", -1, true);
SetLocalVarInt("lever3bank", 1);
CheckFunction();
}
}

//////////////////////////////////////////////////////////////////////

void lever4func(string &in asEntity, int alState)
{
if(alState == 1)
{
SetLeverStuckState("LEVER4", 1, true);
SetLocalVarInt("lever4bank", 1);
CheckFunction();
}
if(alState == -1)
{
SetLeverStuckState("LEVER4", -1, true);
SetLocalVarInt("lever4bank", 0);
}
}

//////////////////////////

void CheckFunction() //custom function called each time a lever is correctly in place. when all are in place, the function continues.
{
if(GetLocalVarInt("lever1bank") == 1 && GetLocalVarInt("lever2bank") == 1 && GetLocalVarInt("lever3bank") == 1 && GetLocalVarInt("lever4bank") == 1)
{
SetEntityActive("LEVER1", false);
SetEntityActive("LEVER2", false);
SetEntityActive("LEVER3", false);
SetEntityActive("LEVER4", false);
SetEntityActive("LEVER1_1", true);
SetEntityActive("LEVER2_1", true);
SetEntityActive("LEVER3_1", true);
SetEntityActive("LEVER4_1", true);
SetLeverStuckState("LEVER1_1", 1, false);
SetLeverStuckState("LEVER2_1", 1, false);
SetLeverStuckState("LEVER3_1", -1, false);
SetLeverStuckState("LEVER4_1", 1, false);

GiveSanityBoost();
SetSwingDoorLocked("LEVERDOOR", false, true);
}
}






I'm assuming the Duplicates will have a _1 at the end of the original name.


Ya dig?
(NOTE:May not be Genius...BACKUPS BEFORE COMPLAINING)

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
01-15-2012, 11:53 AM
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 Tripication - 01-15-2012, 11:53 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)