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

Posts: 160
Threads: 39
Joined: Jun 2011
Reputation: 0
#1
lever problems

can someone please help with the levers?

i want the levers to be like it is in La Caza, and the machine room in original amnesia Smile

pleaz help meh Shy

06-29-2011, 05:38 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#2
RE: lever problems

Here is an example I made quite a while ago that deals with pulling levers in a combination to unlock a door. You can take it and use it only if you edit parts of the scripts to be unique from mine. Smile

http://www.megaupload.com/?d=IXUUH1K3

06-29-2011, 06:17 PM
Find
Dizturbed Offline
Member

Posts: 160
Threads: 39
Joined: Jun 2011
Reputation: 0
#3
RE: lever problems

Woooow, that script was confusing :/ dont know anything about those kind of scripts, help pleaze? Tongue

06-29-2011, 08:14 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#4
RE: lever problems

(06-29-2011, 08:14 PM)Dizturbed Wrote: Woooow, that script was confusing :/ dont know anything about those kind of scripts, help pleaze? Tongue

You can think of it as more C++ than pre-made Amnesia functions. Tongue

I personally think that this is just some basic arithmetic and algebraic mathematics. It's not too hard if you know what you want to happen very specifically. To be honest, I tried explaining this to the person who I originally first made it for and it took a while for them to understand it. I don't think I could try to explain it again. :/

06-29-2011, 08:27 PM
Find
HumiliatioN Offline
Posting Freak

Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation: 18
#5
RE: lever problems

This is my script why it's not working?

SetEntityConnectionStateChangeCallback("lever_1", "L1"); // So when the player interacts with one of these levers, it calls the function to do whatever it says inside them.
SetEntityConnectionStateChangeCallback("lever_2", "L2");
SetEntityConnectionStateChangeCallback("lever_3", "L3");
SetEntityConnectionStateChangeCallback("lever_4", "L4");
}

void Correct() // This function is called when the game sees "Correct();" in the code.
{
GiveSanityBoost(); // If the player starts with 100 sanity, there will be no sanity boost visable because sanity is already at it's max.
SetSwingDoorLocked("cabinet_simple_2", false, true); // I didn't add a sound so don't be surprized and then assume it didn't work. Tongue
}
void L1(string &in asEntity, int alState)
{
if (alState == 1) // This checks to see if the player pulls the lever down, instead of up which would be -1.
{
if(GetLocalVarInt("Lev") == 3) // This checks to see if the local variable integer "Lev" equals 3.
{
SetLocalVarInt("Lev", 4);
SetEntityInteractionDisabled("lever_1", true);
SetLeverStuckState("lever_1", 1, true);
return;
}
else if (GetLocalVarInt("Lev") != 3) // If it doesn't equal, then it sets the levers interactable again and removes the stuck-ness of the levers.
{
SetLocalVarInt("Lev", 1);
for (int i = 1; i > 0 && i < 5; i++)
{
SetEntityInteractionDisabled("lever_"+i, false); // This may look advanced, but what it really is doing is simplifying it to where you don't have to set the lever's interactablility for each lever individually.
}
for (int x = 1; x > 0 && x < 5; x++)
{
SetLeverInteractionDisablesStuck("lever_"+x, true); // The easier way to say this is to do this: SetLeverInteractionDisablesStuck("lever_1", true);
} // SetLeverInteractionDisablesStuck("lever_2", true);
return; // SetLeverInteractionDisablesStuck("lever_3", true);
} // SetLeverInteractionDisablesStuck("lever_4", true);
}
}
void L2(string &in asEntity, int alState)
{
if (alState == 1)
{
if(GetLocalVarInt("Lev") == 2)
{
SetLocalVarInt("Lev", 3);
SetEntityInteractionDisabled("lever_2", true);
SetLeverStuckState("lever_2", 1, true);
return;
}
else if (GetLocalVarInt("Lev") != 2)
{
SetLocalVarInt("Lev", 1);
for (int i = 1; i > 0 && i < 5; i++)
{
SetEntityInteractionDisabled("lever_"+i, false);
}
for (int x = 1; x > 0 && x < 5; x++)
{
SetLeverInteractionDisablesStuck("lever_"+x, true);
}
return;
}
}
}
void L3(string &in asEntity, int alState)
{
if (alState == 1)
{
if(GetLocalVarInt("Lev") == 4)
{
SetLocalVarInt("Lev", 5);
SetEntityInteractionDisabled("lever_3", true);
SetLeverStuckState("lever_3", 1, true);
Correct(); // This asks for the game to call function "void Correct()" because this is the last lever that needs to be pulled.
return;
}
else if (GetLocalVarInt("Lev") != 4)
{
SetLocalVarInt("Lev", 1);
for (int i = 1; i > 0 && i < 5; i++)
{
SetEntityInteractionDisabled("lever_"+i, false);
}
for (int x = 1; x > 0 && x < 5; x++)
{
SetLeverInteractionDisablesStuck("lever_"+x, true);
}
return;
}
}
}
void L4(string &in asEntity, int alState)
{
if (alState == 1)
{
if(GetLocalVarInt("Lev") == 1)
{
SetLocalVarInt("Lev", 2);
SetEntityInteractionDisabled("lever_4", true);
SetLeverStuckState("lever_4", 1, true);
return;
}
else if (GetLocalVarInt("Lev") != 1)
{
SetLocalVarInt("Lev", 1);
for (int i = 1; i > 0 && i < 5; i++)
{
SetEntityInteractionDisabled("lever_"+i, false);
}
for (int x = 1; x > 0 && x < 5; x++)
{
SetLeverInteractionDisablesStuck("lever_"+x, true);
}
return;
}
}
}


Only lever_4 when I pushed that down its only activated one :/ and its stuck then... Help!

“Life is a game, play it”
06-30-2011, 10:35 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#6
RE: lever problems

Where is your LocalVarInt?

06-30-2011, 10:39 PM
Find
HumiliatioN Offline
Posting Freak

Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation: 18
#7
RE: lever problems

(06-30-2011, 10:39 PM)Kyle Wrote: Where is your LocalVarInt?

What I dont know what Im doing here with this script very confusing.

Just copied your testmap script and put somewhere 4 levers to open that "closet" Explain what Im missing and wrote "working script" Smile

“Life is a game, play it”
07-01-2011, 09:14 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#8
RE: lever problems

It should work if you got it all right name-wise if you copied it all directly from the script.

07-01-2011, 11:40 PM
Find
HumiliatioN Offline
Posting Freak

Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation: 18
#9
RE: lever problems

(07-01-2011, 11:40 PM)Kyle Wrote: It should work if you got it all right name-wise if you copied it all directly from the script.

I copied whole script as you have, not working :/

“Life is a game, play it”
07-02-2011, 12:08 AM
Find
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




Users browsing this thread: 1 Guest(s)