![]() |
Let's play "why doesn't my 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: Let's play "why doesn't my script work?"! (/thread-21137.html) Pages:
1
2
|
Let's play "why doesn't my script work?"! - Streetboat - 04-12-2013 Okay, so here's the scenario. Four valves (each starting at the middle position) turn in a specific order to open a portcullis. The correct order goes as such: R R L R. If the player gets one wrong, steam spurts out of a pipe and the order resets. Seems simple enough, right? Right. Here's the code. Code: void valve1turn(string &in asEntity, int alState) Here's where it sucks. If I input the correct order, nothing happens. The portcullis is still stuck there. If I move any of the wheels other than the third to any position, nothing happens. Left or right, wheels 1, 2, and 4 do nothing. Wheel 3 acts as it should; right (the wrong direction) does the steam thing and resets the wheels, and left clicks as it should. So, what do? Why won't this work? I feel like my logic is fairly sound withing the coding. It's late, and I don't want to work on this any more, so I was hoping someone more experienced had some insight. ![]() RE: Let's play "why doesn't my script work?"! - Romulator - 04-12-2013 Assuming the wheels function similarly to the levers and the wheel that you turn to work the burner near the end of the main game, wouldn't script calculate it as the wheel end positions being at -1 and 1? And if not that, then maybe similar to the cogwheel levers in the sewer? They end at 0 and 2. What you could also do is add Debug Messages in the coding of your 1st, 2nd and 4th wheels. You may through this be able to determine exactly where your code is going wrong. RE: Let's play "why doesn't my script work?"! - Streetboat - 04-12-2013 Ha, I'm an idiot. You're absolutely right, the problem was that they started at 0 and ended at 1. I blame the fact that I was tired. ![]() However, the issue still remains that when I do it all right, the door doesn't move at all. I'm certain it's a moveobject, I've used it before... RE: Let's play "why doesn't my script work?"! - Your Computer - 04-12-2013 Why do you have three functions that do exactly the same thing? RE: Let's play "why doesn't my script work?"! - Streetboat - 04-12-2013 Where? There are four valves, and each function pertains to a different valve. What do you mean? RE: Let's play "why doesn't my script work?"! - Your Computer - 04-12-2013 valve1turn, valve2turn and valve4turn do the exact same thing (valve3turn only differs in the state checks). The issue, however, that i can spot is that you're adding to the local map variable more times than you should. Turn one valve correctly, the local map variable becomes 2 by the time the function ends. Turn the second valve correctly, it adds up to 3, notices that it doesn't equal 4 and then moves on to the else, adding up to 4. Turn the third valve correctly, the local map variable adds up to 5, and so on. Therefore, even though the variable reaches 4 at some point, it is never at 4 when checked for 4; it is either greater than or less than 4 at the time it is checked. RE: Let's play "why doesn't my script work?"! - Streetboat - 04-12-2013 Thank you. I will look into that tomorrow. ![]() RE: Let's play "why doesn't my script work?"! - Romulator - 04-12-2013 It always takes me so long to reply. You can read this if you want, but I'm sure you would have the general idea already There are two ways I believe you could fix this from past experience... (I'm a nooby scripter ![]() 1. Make the door explode ![]() Code: SetPropHealth("<portcullis>", 0.0f); Code: SetSwingDoorLocked("<portcullis>", false, true); ![]() Code: Change: I may not be the best but that MAY help or give you an insight as to what to do ![]() RE: Let's play "why doesn't my script work?"! - PutraenusAlivius - 04-12-2013 (04-12-2013, 09:08 AM)Your Computer Wrote: valve1turn, valve2turn and valve4turn do the exact same thing (valve3turn only differs in the state checks). The issue, however, that i can spot is that you're adding to the local map variable more times than you should. Turn one valve correctly, the local map variable becomes 2 by the time the function ends. Turn the second valve correctly, it adds up to 3, notices that it doesn't equal 4 and then moves on to the else, adding up to 4. Turn the third valve correctly, the local map variable adds up to 5, and so on. Therefore, even though the variable reaches 4 at some point, it is never at 4 when checked for 4; it is either greater than or less than 4 at the time it is checked. Oh yeah. So it should be changed to PHP Code: if(GetLocalVarInt("gateopen") >= 4) RE: Let's play "why doesn't my script work?"! - Romulator - 04-12-2013 As long as the outcome does not reach an integer >= 4 before all four valves are turned to the correct position, it should work fine ![]() |