![]() |
[SCRIPT] How to make a "Wait" in the script. - 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] How to make a "Wait" in the script. (/thread-14684.html) Pages:
1
2
|
How to make a "Wait" in the script. - iFondue - 04-10-2012 Hello, I'm pretty new to this forum and i have a question. ![]() I already searched in the forum for answers, but I didn't find anything. I know that the title is a little complicated, but I am going to explain what I mean... ![]() Idea: I am working on a custom story for a week now, but now I am stuck at this problem. I made the player look at the corridor (StartPlayerLookAt). Now I want to light always 2 lamps, lamp after lamp when i enter "ScriptArea_1". But i want that between the lightning of the lamps is always like 0.5 seconds... I know that i have to do that with a timer (I think? ![]() Could someone expain? ![]() This is my script: Run when entering map void OnEnter() { AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1); } void LightOn(string &in asParent, string &in asChild, int alState) { AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1); StartPlayerLookAt("LookFrame", 20, 50, ""); SetLampLit("candlestick_1", true, true); SetLampLit("candlestick_2", true, true); Wait 0.5 Seconds Light Lamp 3 and 4 (SetLampLit) Wait 0.5 Seconds Light Lamp 4 and 5 (SetLampLit) ....... StopPlayerLookAt(); } I think you got the idea... ? Greets -iFondue RE: How to make a "Wait" in the script. - Putmalk - 04-10-2012 Here's how I would do it: Code: void LightOn(string &in asParent, string &in asChild, int alStat) RE: How to make a "Wait" in the script. - iFondue - 04-10-2012 Hey, thank you very much for your fast reply. It now looks like this: void LightOn(string &in asParent, string &in asChild, int alStat) { AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1); StartPlayerLookAt("LookFrame", 20, 50, ""); SetLampLit("candlestick_1", true, true); SetLampLit("candlestick_2", true, true); AddTimer("light1", 0.5f, "TimerLight"); AddTimer("light2", 1, "TimerLight"); AddTimer("stopeffects", 1.2f, "TimerLight"); } void TimerLight(string &in asTimer) { if(asTimer == "light1") { SetLampLit("candlestick_3", true, true); SetLampLit("candlestick_4", true, true); } if(asTimer == "light2") { SetLampLit("candlestick_5", true, true); SetLampLit("candlestick_6", true, true); } if(asTimer == "stopeffects") { StopPlayerLookAt(); } } Unfortunately the other lamps won't light. Did I do something wrong? Did I forget something? Greets -iFondue RE: How to make a "Wait" in the script. - Putmalk - 04-10-2012 I just double checked the code...it should be fine... Could you add a test SetMessage or something inside the if statements to make sure they're running? RE: How to make a "Wait" in the script. - iFondue - 04-10-2012 Hmmmm... I tried to do a PlaySoundAtEntity but I couldn't hear anything.... Any ideas? Greets -iFondue RE: How to make a "Wait" in the script. - Putmalk - 04-10-2012 I'm having trouble understanding why there's a problem because I performed a similar solution in my own map, here's just a snippet: Code: AddTimer("opendoor", 0.25f, "TimerOpenDoor"); ^^ And that works just fine. Is the code working correctly? The function TimerLight isn't working? This is weird.... Outside the if statements, in TimerLight, put a command. If that doesn't work, then the whole function isn't working, and it's just an error when calling it. Oh yeah, so I don't forget, is the script working at all? Are other functions working correctly? RE: How to make a "Wait" in the script. - iFondue - 04-10-2012 Well, this is how it looks right: void TimerLight(string &in asTimer) { if(asTimer == "light1") { SetLampLit("candlestick_3", true, true); SetLampLit("candlestick_4", true, true); } if(asTimer == "light2") { SetLampLit("candlestick_5", true, true); SetLampLit("candlestick_6", true, true); } if(asTimer == "stopeffects") { StopPlayerLookAt(); } } It's correct isn't it? There is no error, when starting, it's just that the light's won't lit.... Is there another way to do it, or did I do something wrong? Greets -iFondue RE: How to make a "Wait" in the script. - Putmalk - 04-10-2012 Copied the code into Programmer's Notepad so I can see it easier, let's see... void LightOn(string &in asParent, string &in asChild, int alStat) should be void LightOn(string &in asParent, string &in asChild, int alState), try that.... Also, In your LightOn function, you're creating an entity collide callback to LightOn, how come? Shouldn't that be placed in OnStart()? RE: How to make a "Wait" in the script. - iFondue - 04-10-2012 Okay, I changed the State. But what has to go to OnStart () ? Only the LightOn function? Greets -iFondue RE: How to make a "Wait" in the script. - Putmalk - 04-10-2012 (04-10-2012, 06:27 PM)iFondue Wrote: Okay, I changed the State.Nah, "AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);" does. Generally, you put your callbacks in the OnStart function, unless you want that event to happen at a specific time, at which you'll put it in a different place. |