Trouble with Timers - 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: Trouble with Timers (/thread-26963.html) |
Trouble with Timers - ADrySoldier - 10-25-2014 So I have recently started to make a Custom Story, and everything was going great until I got to this one part in my .lang file. Here it is: void OnStart() { } AddEntityCollideCallback("Player", "ScriptArea_1", "BoardDoor", true, 1); // Set Player to Sleeping Position SetPlayerActive(false); FadeOut(0.0f); SetPlayerCrouching(true); MovePlayerHeadPos(0, -0.75f, 0, 10, 0); FadePlayerRollTo(37.75f, 10, 10); // Ready Timer for Wake AddTimer("Time1", 2.5f, "Wake"); } } void OnEnter() { PlayMusic("", true, 0.9, 1.0, 1, true); } void OnLeave() { StopMusic(1 , 1); } void Wake(string &in asTimer) { // string &in asTimer is always used when setting up a Timer Callback // Set Player to a awoken position FadeIn(0.7f); FadePlayerRollTo(0.0f, 6.5, 7); // Ready Timer for EventDoor AddTimer("Time2", 5.0f, "EventDoor"); } void EventDoor(string &in asTimer) { // Player looks at door, says Robbers! and gets up StartPlayerLookAt("metal_1", 4.5f, 5, ""); SetMessage("Messages", "robbers", 3); MovePlayerHeadPos(0, 0, 0, 4.5f, 3); // Ready timer for Move AddTimer("Move", 2.0f, "Move"); } void Move(string &in asTimer) { StopPlayerLookAt(); SetPlayerActive(true); } void BoardDoor(string &in asParent, string &in asChild, int alState) { SetPlayerActive(false); FadeOut(0.5f); AddTimer("PlaySound", 1.5f, "PlaySound"); } void PlaySound(string &in asTimer) { TeleportPlayer("PlayerStartArea_2"); PlayGuiSound("15_hammer.snt", 100); AddTimer("PlaySound2", 0.8f, "PlaySound2"); } void PlaySound2(string &in asTimer) { PlayGuiSound("15_hammer.snt", 100); AddTimer("PlaySound3", 0.8f, "PlaySound3"); } void PlaySound3(string &in asTimer) { PlayGuiSound("15_hammer.snt", 100); AddTimer("PlaySound4", 0.8f, "PlaySound4"); } void PlayGuiSound4(string &in asTimer) { PlayGuiSound("15_hammer.snt", 100); AddTimer("FadeIn", 0.5f, "FadeIn"); } void FadeIn(string &in asTimer) { FadeIn(0.5f); AddTimer("blockcade", 0.0f, "blockcade"); } void blockcade(string &in asTimer) { SetEntityActive("cabinet_nice_2", true); SetEntityActive("chair_wood02_2", true); SetEntityActive("chair_wood02_3", true); SetEntityActive("chair_wood02_1", true); SetEntityActive("cabinet_nice_1", false); SetEntityActive("shirt_hanging_white_1", true); SetEntityActive("shirt_hanging_white_2", true); AddTimer("Finish", 0.0f, "Finish"); } void Finish(string &in asTimer) { SetMessage("Messages", "doneboards", 3); AddTimer("LookUp", 2.0f, "LookUp"); } void LookUp(string &in asTimer) { SetEntityActive("fallingrock", true); AddEntityCollideCallback("fallingrock", "ScriptArea_2", "Faint", true, 1); StartPlayerLookAt("fallingrock", 4.5f, 5, ""); } void Faint(string &in asParent, string &in asChild, int alState) { FadeOut(0.3f); StopPlayerLookAt(); } After PlayGuiSound4 that the player is stuck there because of SetPlayerActive. It's supposed to show a barricade at the door at via the SetEntities but nothing happens and I am tearing my hair out looking it up online and seeing long since dead threads. I don't know what the problem is, and if it's even the timer. Please help. Here's a picture of the CS I am working on: [attachment=4812] I made a demo on ModDB but that was when I was first trying so it sucks majorly. This is a reboot that is a completely new idea with the same name. Thanks for looking. RE: Trouble with Timers - Romulator - 10-26-2014 Can I first say that I am surprised your code actually works: PHP Code: void OnStart() On the third line, you have a closing brace which would close the OnStart(), and generate errors for the rest of that set of code there. Edit: If you remove that closing brace, remove another at the bottom of the OnStart() area as well. If you do not fully understand, this is what your code should look like: Spoiler below!
Now, I do not think you can call timers at 0.0f. You CAN however change the two which happen instantly by changing 0.0f to 0.001f, which is practically instantaneous. Give that an attempt, otherwise I do not know exactly what is wrong. Perhaps I misread some syntax, but the game would return an error in that case. RE: Trouble with Timers - Mudbill - 10-26-2014 I do know you can call a timer with 0.0f as the time, however instead of doing PHP Code: AddTimer("timer", 0.0f, "TimerFunc"); PHP Code: TimerFunc("timer"); |