![]() |
[SCRIPT] Why won't this script work? - 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] Why won't this script work? (/thread-11907.html) |
Why won't this script work? - ferryadams10 - 12-17-2011 Hi guys. What I'm trying to do is make the SlideDoor2 go open when I've set all levers in a proper order. lever_1, 3 and 4 should be down lever_2 and 5 should be up. But.. Now the PerformLeverTaskCompleted starts working as soon as I pull just a random lever. Please help me to make the SlideDoor2 open when I put em in the right order. ![]() PHP Code: //////////////////////////// RE: Why won't this script work? - palistov - 12-17-2011 Your syntax is all correct but your semantics is all out of whack. Semantics is basically programming "grammar", while syntax is programming "spelling". Your code is syntactically correct, but if you take a look at your function StoreCheckLeverState, you'll notice that no matter what lever is pulled, the variables are all set to the correct state. Hence, the player can pull any one lever and solve the puzzle. To solve this, use this function instead PHP Code: void StoreCheckLeverState(string &in entity, int state) Good luck ![]() RE: Why won't this script work? - Dobbydoo - 12-17-2011 (12-17-2011, 05:18 PM)palistov Wrote: Your syntax is all correct but your semantics is all out of whack. Semantics is basically programming "grammar", while syntax is programming "spelling". Your code is syntactically correct, but if you take a look at your function StoreCheckLeverState, you'll notice that no matter what lever is pulled, the variables are all set to the correct state. Hence, the player can pull any one lever and solve the puzzle. To solve this, use this function insteadIt would be much easier to have only one variable for all levers. Then every time you pull a lever you add one to the variable and when it reaches 6 the puzzle is completed. RE: Why won't this script work? - Your Computer - 12-17-2011 There's no point to check for the lever name from the entity variable if the local map variable carries the same name. PHP Code: void StoreCheckLeverState(string &in entity, int state) (12-17-2011, 05:29 PM)Dobbydoo Wrote: It would be much easier to have only one variable for all levers. Then every time you pull a lever you add one to the variable and when it reaches 6 the puzzle is completed. That would be error prone. Even if we set a stuck state for each lever when it gets pulled correctly, you'd still be adding 1 for when it gets pulled in the opposite, undesired direction. RE: Why won't this script work? - ferryadams10 - 12-17-2011 Thanks allot. It worked ![]() RE: Why won't this script work? - palistov - 12-17-2011 Your Computer, just showing him the simplest and easiest-to-understand solution ![]() RE: Why won't this script work? - Dobbydoo - 12-17-2011 (12-17-2011, 06:16 PM)Your Computer Wrote: There's no point to check for the lever name from the entity variable if the local map variable carries the same name.Not if he only added to the variable when it was in the right state, and maybe made it stuck when in that state. Like this: PHP Code: if(alState == 1) EDIT: And of course when not being in the right state one would be removed from the variable. RE: Why won't this script work? - ferryadams10 - 12-21-2011 Haha thanks Dobbydoo but it was already working ^^ Thanks for being so helpfull against me anyways ![]() |