3buttons then a bookshelf opens - 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 (https://www.frictionalgames.com/forum/forum-35.html) +--- Thread: 3buttons then a bookshelf opens (/thread-8578.html) Pages:
1
2
|
3buttons then a bookshelf opens - xtron - 06-13-2011 I already know how to make so when you pull 1lever a bookshelf opens but I don't have any ideas on how to do so when you push 3 buttons a secret bookshelf opens :O I appreciate if you guys could help me fix this :/ RE: 3buttons then a bookshelf opens - Kyle - 06-13-2011 Code: void OnStart() Edit: Oops, here you go, this one is right now. RE: 3buttons then a bookshelf opens - Nye - 06-13-2011 (06-13-2011, 07:50 PM)xtron Wrote: bump... Set the interact callbacks for each of the levers. Set the 'DestroyOnInteraction' to true for each; and link them all to the same procedure. Here, you will need to either use a case-switch structure or just a bunch of if statements, and local variables. For example: Code: if (getlocalvarint("BookShelf") == 1) Note, for the above to work, the local variable, "BookShelf", will previously need setting to 1, so in your void onStart() { // you need to include the line, "setlocalvarint("BookShelf", 1);". Hope this helps somewhat. RE: 3buttons then a bookshelf opens - xtron - 06-13-2011 @Nye Could you please explain your code a little more?. Where should I add the 3 buttons and the code which dose so the bookshelf opens? Here's my code for opening a bookshelf if you drag 1lever. Code: ConnectEntities("door_connection", //Name of connection RE: 3buttons then a bookshelf opens - Kyle - 06-13-2011 @Xtron; Thanks for ignoring my reply... :/ It should work like this: 1. Player pushes a button and a local variable is incremented by 1. 2. Same thing happens for the other 2 buttons. 3. Since they were all pushed, the bookshelf slides over to reveal a secret door. RE: 3buttons then a bookshelf opens - xtron - 06-13-2011 Oh sorry Kyle :S. Forgot about yours. . But Kyle...since your so kind you can maybe give me a start on how to set the script up?. I tried to understand both your and Nye's script but didn't made it :/. RE: 3buttons then a bookshelf opens - Kyle - 06-13-2011 (06-13-2011, 08:38 PM)xtron Wrote: Oh sorry Kyle :S. Forgot about yours. . To set it up, first you need to keep track of whether the player pushes the buttons. So you need a local variable which can be used within the whole script. SetLocalVarInt("Var01", 0); The name of it is "Var01" and it's value is 0. Now we need to change it's value when the player interacts with each button. So we add interactions for each button. For button 1 which will be called "Button_1": SetEntityPlayerInteractCallback("Button_1", "Func_1", true); For button 2 which will be called "Button_2": SetEntityPlayerInteractCallback("Button_2", "Func_2", true); For button 3 which will be called "Button_3": SetEntityPlayerInteractCallback("Button_3", "Func_3", true); So now we have a function for each individual button. Functions: "Func_1", "Func_2", and "Func_3". Buttons: "Button_1", "Button_2", and "Button_3". We can simplify it to where you only need 1 function. Lets just call it "Func_1". This is what it'll look like: void Func_1(string &in asEntity) { AddLocalVarInt("Var01", 1); } Now in the void OnStart() function, we need to call another function. Lets call it "FuncOpen". Now inside of that function, we need to check and see if the variable is equal to 3. Let me represent it by this: Buttons Pressed By Player = Var01 = 3 ---> 3 = BookShelf Slides Open So most of the script should look like this: Code: void OnStart() RE: 3buttons then a bookshelf opens - xtron - 06-14-2011 Thanks kyle! . But it doesn't work for me :S Code: void OnStart() RE: 3buttons then a bookshelf opens - Apjjm - 06-15-2011 Tweaked and re-arranged the code a little, by moving the buttons into an array so you can add/remove/change the buttons easily (you can just add any extra buttons to the array and without needing to alter the code at all). The code wasn't working because FuncOpen() was only being called from the start routine, and not the callback. Code: //List of all our buttons. You can add or remove buttons really easily from this This may also interest you: http://www.frictionalgames.com/forum/thread-8484-post-74705.html#pid74705 RE: 3buttons then a bookshelf opens - xtron - 06-15-2011 Thanks Apjjm! your the best! <3. Great love to you Kyle aswell for trying to help me <3. |