Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
lever problems
rojkish Offline
Junior Member

Posts: 45
Threads: 0
Joined: Jun 2011
Reputation: 0
#10
RE: lever problems

Begin with;

Spoiler below!

void OnStart()
{
for(int i=1; i<=3;i++) SetEntityConnectionStateChangeCallback("lever_"+i, "L_"+i);
//This means that it'll be three functions, i.e;

//for(int i=1; i<=3;i++)

//int i=1; the int i is 1;
//i<=3; if i is less than 3;
//i++; plus i three times;

//It will look like this;
//SetEntityConnectionStateChangeCallback("lever_1", "L_1");
//SetEntityConnectionStateChangeCallback("lever_2", "L_2");
//SetEntityConnectionStateChangeCallback("lever_3", "L_3");
}


After you've made that, you wanna make three functions; L_1, L_2, L_3, each one setting a VarInt, and when the VarInt of all the levers are set, the function happens (move a shelf or whatever). Adding a timer is also important, seeing as how the levers should stop after a certain amount of time (remove if you don't want it).

Spoiler below!

void L_1(string &in EntityName, int alState)
{
SetLocalVarInt("L1", 1);

if(alState == -1) //If the state of the lever is -1 (it's down iirc. 1 is up)
{
AddLocalVarInt("L1", 2);

AddTimer("StopTick", 10, "StopTick"); //Timer to stop the sound, that is if you want to include any, perhaps gameplay_tick
}

if(GetLocalVarInt("L1") == 2) && GetLocalVarInt("L2") == 2) && GetLocalVarInt("L3") == 2) //this function is added to all three of them so it can happen even if you start with the third
{
//DO YOUR FUNCTION HERE, EITHER IF YOU WANT TO UNLOCK A DOOR OR MOVE A SHELF

RemoveTimer("StopTick");
}
}

void L_2(string &in EntityName, int alState)
{
SetLocalVarInt("L2", 1);

if(alState == -1)
{
AddLocalVarInt("L2", 2);

AddTimer("StopTick", 10, "StopTick"); //Timer to stop the sound, that is if you want to include any, perhaps gameplay_tick
}

if(GetLocalVarInt("L1") == 2) && GetLocalVarInt("L2") == 2) && GetLocalVarInt("L3") == 2) //this function is added to all three of them so it can happen even if you start with the third
{
//DO YOUR FUNCTION HERE, EITHER IF YOU WANT TO UNLOCK A DOOR OR MOVE A SHELF

RemoveTimer("StopTick");
}
}

void L_3(string &in EntityName, int alState)
{
SetLocalVarInt("L3", 1);

if(alState == -1)
{
AddLocalVarInt("L3", 2);

AddTimer("StopTick", 10, "StopTick"); //Timer to stop the sound, that is if you want to include any, perhaps gameplay_tick
}

if(GetLocalVarInt("L1") == 2) && GetLocalVarInt("L2") == 2) && GetLocalVarInt("L3") == 2) //this function is added to all three of them so it can happen even if you start with the third
{
//DO YOUR FUNCTION HERE, EITHER IF YOU WANT TO UNLOCK A DOOR OR MOVE A SHELF

RemoveTimer("StopTick");
}
}

void StopTick(string &in asTimer)
{
for(int i=1;i<=3;i++)
{
StopSound("Tick"+i, 2);
SetLocalVarInt("L"+i, 1);
}
}



Remember to name your levers; lever_1, lever_2, lever_3 and write the final function in L_1, L_2 and L_3.

(Feel free to add stuff as noise, particlesystems or whatever you like whereever you like, since I haven't fixed any - at my laptop atm. I would also add stuff such as SetLeverStuckState(string& asName, int alState, bool abEffects); when you successfully drag the levers down to -1 and make them unstuck and go to the middle (can't remember the script for this one) when the timer StopTick happens)

Tell if it doesn't work, can't test it since I'm on my laptop atm. ^_^
(This post was last modified: 07-02-2011, 12:45 AM by rojkish.)
07-02-2011, 12:39 AM
Find


Messages In This Thread
lever problems - by Dizturbed - 06-29-2011, 05:38 PM
RE: lever problems - by Kyle - 06-29-2011, 06:17 PM
RE: lever problems - by Dizturbed - 06-29-2011, 08:14 PM
RE: lever problems - by Kyle - 06-29-2011, 08:27 PM
RE: lever problems - by HumiliatioN - 06-30-2011, 10:35 PM
RE: lever problems - by Kyle - 06-30-2011, 10:39 PM
RE: lever problems - by HumiliatioN - 07-01-2011, 09:14 AM
RE: lever problems - by Kyle - 07-01-2011, 11:40 PM
RE: lever problems - by HumiliatioN - 07-02-2011, 12:08 AM
RE: lever problems - by rojkish - 07-02-2011, 12:39 AM
RE: lever problems - by Kyle - 07-02-2011, 09:59 PM



Users browsing this thread: 1 Guest(s)