![]() |
[SCRIPT] Multiple Levers - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: [SCRIPT] Multiple Levers (/thread-12774.html) Pages:
1
2
|
Multiple Levers - i3670 - 01-22-2012 Hi! I have these levers that need to be pulled in a certain order for a door to open. The problem is of course that it isn't working. void OnStart() { SetLocalVarInt("Var1", 0); SetEntityPlayerInteractCallback("button_1", "func1", true); SetEntityPlayerInteractCallback("button_2", "func2", true); SetEntityPlayerInteractCallback("button_3", "func3", true); SetEntityPlayerInteractCallback("button_4", "func4", true); } void func1(string &in asEntity) { AddLocalVarInt("Var1", 1); func5(); } void func2(string &in asEntity) { AddLocalVarInt("Var1", 1); func5(); } void func3(string &in asEntity) { AddLocalVarInt("Var1", 1); func5(); } void func4(string &in asEntity) { AddLocalVarInt("Var1", 1); func5(); } void func5() { if(GetLocalVarInt("Var1") == 4) { SetEntityActive("castle_gate_arched01_1", false); SetEntityActive("castle_gate_arched01_2", true); } } RE: Multiple Levers - Tripication - 01-22-2012 Is there an error report, or will it just not work? and are you sure you dont want castle_gate_arched01_open? oh, you used the wrong callback(if your using levers) you should have void OnStart() { SetLocalVarInt("Var1", 0); SetEntityConnectionStateChangeCallback("lever", "func1"); SetEntityConnectionStateChangeCallback("lever", "func2"); SetEntityConnectionStateChangeCallback("lever", "func3"); SetEntityConnectionStateChangeCallback("lever", "func4"); } void func1(string &in asEntity) { AddLocalVarInt("Var1", 1); func5(); } void func2(string &in asEntity) { AddLocalVarInt("Var1", 1); func5(); } void func3(string &in asEntity) { AddLocalVarInt("Var1", 1); func5(); } void func4(string &in asEntity) { AddLocalVarInt("Var1", 1); func5(); } void func5() { if(GetLocalVarInt("Var1") == 4) { SetEntityActive("castle_gate_arched01_1", false); SetEntityActive("castle_gate_arched01_2", true); } } RE: Multiple Levers - i3670 - 01-22-2012 (01-22-2012, 12:09 PM)Tripication Wrote: Is there an error report, or will it just not work?I can enter the map in game without an error message. But when I pull the levers nothing happens. The door in question is the great big castle door which cannot be opened so I did it like this with SetEntityActive. RE: Multiple Levers - Tripication - 01-22-2012 Previous post(i edited it) And there is a seperate entity that is already open, cracked enough so the player can get through fuck, hang on, that wont be all to the script... There, This script should be right. It should make it so that when the player pulls down on each lever, it will add 1 to the Variable. When the variable is fulfilled, it will process func5 void OnStart() { SetLocalVarInt("Var1", 0);//CREATES VARIABLE SetEntityConnectionStateChangeCallback("lever", "func1");//CREATES FUNC1 SetEntityConnectionStateChangeCallback("lever", "func2");//CREATES FUNC2 SetEntityConnectionStateChangeCallback("lever", "func3");//CREATES FUNC3 SetEntityConnectionStateChangeCallback("lever", "func4");//CREATES FUNC4 } void func1(string &in asEntity)//STARTS FUNC1 { if (alState == 1)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING { AddLocalVarInt("Var1", 1); func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE } } void func2(string &in asEntity)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING { if (alState == 1) { AddLocalVarInt("Var1", 1); func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE } } void func3(string &in asEntity)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING { if (alState == 1) { AddLocalVarInt("Var1", 1); func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE } } void func4(string &in asEntity)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING { if (alState == 1) { AddLocalVarInt("Var1", 1); func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE } } void func5()//STARTS FUNC5 { if(GetLocalVarInt("Var1") == 4)//IF VARIABLE IS FULFILLED, IT WILL EXECUTE THE FOLLOWING { SetEntityActive("castle_gate_arched01_1", false); SetEntityActive("castle_gate_arched01_2", true); } } Im going to have to thank Statyk, flamez, your computer, Elven, russ money and Apjjm(and anyone else that doesn't come to mind) for helping me out with alot of this. They taught me most I know and I really appreciate it. ![]() RE: Multiple Levers - i3670 - 01-22-2012 Ok tried to start the map now, gave me error: 'alState' is not declared Expression must be of boolean type. 256,5 256,5 265,5 265,5 274,5 274,5 283,5 283,5 void func1(string &in asEntity) /254 { if (alState == 1) { AddLocalVarInt("Var1", 1); func5(); } } void func2(string &in asEntity) { if (alState == 1) { AddLocalVarInt("Var1", 1); func5(); } } void func3(string &in asEntity) { if (alState == 1) { AddLocalVarInt("Var1", 1); func5(); } } void func4(string &in asEntity) { if (alState == 1) { AddLocalVarInt("Var1", 1); func5(); } } void func5() { RE: Multiple Levers - Tripication - 01-22-2012 make sure you changed the names of the levers in the void OnStart RE: Multiple Levers - i3670 - 01-22-2012 (01-22-2012, 12:40 PM)Tripication Wrote: make sure you changed the names of the levers in the void OnStartyes they're called button_1 in the map editor and it is button_1 in the OnStart RE: Multiple Levers - Tripication - 01-22-2012 Oh sorry again, wrong syntax this time ill fix here void OnStart() { SetLocalVarInt("Var1", 0);//CREATES VARIABLE SetEntityConnectionStateChangeCallback("LEVER1", "func1");//CREATES FUNC1 SetEntityConnectionStateChangeCallback("LEVER2", "func2");//CREATES FUNC2 SetEntityConnectionStateChangeCallback("LEVER3", "func3");//CREATES FUNC3 SetEntityConnectionStateChangeCallback("LEVER4", "func4");//CREATES FUNC4 } void func1(string &in asEntity, int alState)//STARTS FUNC1 { if (alState == 1)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING { AddLocalVarInt("Var1", 1); func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE } } void func2(string &in asEntity, int alState)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING { if (alState == 1) { AddLocalVarInt("Var1", 1); func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE } } void func3(string &in asEntity, int alState)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING { if (alState == 1) { AddLocalVarInt("Var1", 1); func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE } } void func4(string &in asEntity, int alState)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING { if (alState == 1) { AddLocalVarInt("Var1", 1); func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE } } void func5()//STARTS FUNC5 { if(GetLocalVarInt("Var1") == 4)//IF VARIABLE IS FULFILLED, IT WILL EXECUTE THE FOLLOWING { SetEntityActive("castle_gate_arched01_1", false); SetEntityActive("castle_gate_arched01_2", true); } } RE: Multiple Levers - i3670 - 01-22-2012 Hehe, well the script is sorta working. I can get the things to activate, but not the way I want them to. I'll list the problems: 1. The lever wont stick in the "ON" position. 2. I can just pull any lever 4 times and the script will trigger, activating the gate. RE: Multiple Levers - Tripication - 01-22-2012 Also In this following post, you want the levers to stay stuck afterward, use this addition ______________________________________________________________________________ void OnStart() { SetLocalVarInt("Var1", 0); SetEntityConnectionStateChangeCallback("Lever1", "func1"); SetEntityConnectionStateChangeCallback("Lever2", "func2"); SetEntityConnectionStateChangeCallback("Lever3", "func3"); SetEntityConnectionStateChangeCallback("Lever4", "func4"); } void func1(string &in asEntity, int alState) { if (alState == 1) { AddLocalVarInt("Var1", 1); SetLeverStuckState(Lever1, 1, true); func5(); } } void func2(string &in asEntity, int alState) { if (alState == 1) { AddLocalVarInt("Var1", 1); SetLeverStuckState(Lever2, 1, true); func5(); } } void func3(string &in asEntity, int alState) { if (alState == 1) { AddLocalVarInt("Var1", 1); SetLeverStuckState(Lever3, 1, true); func5(); } } void func4(string &in asEntity, int alState) { if (alState == 1) { AddLocalVarInt("Var1", 1); SetLeverStuckState(Lever4, 1, true); func5(); } } void func5() { if(GetLocalVarInt("Var1") == 4) { SetEntityActive("castle_gate_arched01_1", false); SetEntityActive("castle_gate_arched01_2", true); } } Just add the stuck states Oh you wanted certain order...well theres the Staying in on position, i'll see if i can set something up for the specific order, but i've never done it before...What was the order you wanted? |