Frictional Games Forum (read-only)
[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


RE: How to make a "Wait" in the script. - iFondue - 04-10-2012

You mean like that, do you?


void OnStart()

{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
}


////////////////////////////
// Run when entering map
void OnEnter()

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);


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();
}
}



It's always the same... the two first lamps lit, and all the others not... Sad


Greets

-iFondue


RE: How to make a "Wait" in the script. - Putmalk - 04-10-2012

My next question is, are there entities named "candlestick_3", 4, 5, and 6 on the map?

It should also be

void OnEnter()
{
}

Do you have a map_cache? If so, delete it.



RE: How to make a "Wait" in the script. - iFondue - 04-10-2012

Yes there are candlestick_1, candlestick_2, candlestick_3 .....4,5,6 up to 12!

Changed the { } at on Enter, and deleted the cache.

Now the error comes: FATAL ERROR Could not load Script File.

Main (15/7) Expected '('
Main (32/7) Expected '('

What did I forget?


RE: How to make a "Wait" in the script. - Putmalk - 04-10-2012

Can you post the entire script (encase it in the code tags and the spoilers) so I can fully look at it.

By the way, the reason nothing was changing before was because of that cache.

I need the whole script so I can find the line numbers in my own scripting editor.



RE: How to make a "Wait" in the script. - iFondue - 04-10-2012

Sure here it is:

Code:
////////////////////////////
// Run first time starting map
void OnStart()


{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
}


////////////////////////////
// Run when entering map
void OnEnter()
{

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);
      

      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();
       }
}

}
////////////////////////////
// Run when leaving map
void OnLeave()
{

}





RE: How to make a "Wait" in the script. - Putmalk - 04-10-2012

With void OnEnter() you are missing an end bracket "}".

Had an additional end bracket at the end of "TimerLight".

The code should look like this to end:

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
}


////////////////////////////
// Run when entering map
void OnEnter()
{

}

void LightOn(string &in asParent, string &in asChild, int alState)
{
    //we don't need this callback here, this is will only mess up the code
    //AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
    
    StartPlayerLookAt("LookFrame", 20, 50, "");
    
    SetLampLit("candlestick_1", true, true);
    SetLampLit("candlestick_2", true, true);
    //an alternate, time-saving way to do this is:
    /*
    for(int i=1;i<3;i++) //for loop will run when i is 1 and 2 only
        SetLampLit("candlestick_"+i, true, true);
    */
    //for 2 that isn't necessary but if you were lighting say 30 candles, this is almost a must!

      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();
       }
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

That should be correct, but if you get another error just let me know.



RE: How to make a "Wait" in the script. - iFondue - 04-10-2012

OMG! Thank you so much Putmalk! <3

Now it worked! The lamps lit, one after the other! It's perfect!

You seem to be really good at scripting.

Thank you for taking the time for me!

BTW: Subscribed to your YouTue Channel...


Greets

-iFondue





RE: How to make a "Wait" in the script. - Putmalk - 04-10-2012

(04-10-2012, 07:16 PM)iFondue Wrote: OMG! Thank you so much Putmalk! <3

Now it worked! The lamps lit, one after the other! It's perfect!

You seem to be really good at scripting. Thank you again.


BTW: Subscribed to your YouTue Channel...


Greets

-iFondue
Glad it worked, check out those comments I made, they'll help you out, and I'm glad it worked, sorry it took so long, I didn't realize you had a map cache that was blocking everything.

(always delete that map cache until the very end).

And thanks mate. Smile


RE: How to make a "Wait" in the script. - iFondue - 04-10-2012

No Problem!

Thank you, i think I learned a lot.
that's what important.

I will work on my map now...


Thanks

Greets

-iFondue