Frictional Games Forum (read-only)
[SCRIPT] Sequential Looping 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] Sequential Looping Script (/thread-30425.html)



Sequential Looping Script - AGP - 08-22-2015

All righty, so here's the deal:

I'm putting together a quick little credits sequence, using the SetMessage function (I find that it looks nicer than gimping/photoshopping them), and it's not really turning out. There are five messages altogether.

Code:
void ToBlack(string &in asTimer)
{
    FadeOut(5);
    TeleportPlayer("PlayerStartArea_11");
    
    AddTimer("", 5, "CreditsRoll");
}

void CreditsRoll(string &in asTimer)
{
    for(int i = 1; i <= 5; i++) {
        FadeIn(5);    
        SetMessage("Messages", "credits_"+i, 5);
        AddLocalVarInt("Roll", 1);
        
        if (GetLocalVarInt("Roll") == 5)
             {
                RemoveTimer("CreditsRoll");
             }
            }
            
    AddTimer("", 5, "CreditsRoll");
}

Each message is named credits_1 and is sequential, but for the life of me, it's just not coming together, and I betcha it's an easy fix too. -.-


RE: Sequential Looping Script - FlawlessHappiness - 08-22-2015

You're using the for-loop in an interesting way.

I'm not sure what you were picturing, but I would do something like

PHP Code:
void CreditsRoll(string &in asTimer)
{
AddLocalVarInt("Roll"1//Add 1 to a variable, so it keeps rising.

SetMessage("Messages""credits_"+GetLocalVarInt("Roll"), 5//Show the message, with the added variable.

if(GetLocalVarInt("Roll") < 5//If less than 5, add another timer
{
AddTimer(""5"CreditsRoll");
}


EDIT: Forgot a category in SetMessage


RE: Sequential Looping Script - Mudbill - 08-22-2015

A for-loop does not have any delay to it. If you set it to loop 10 times, it will finish all those 10 times before anything else happens in the game. If it's process-heavy, it will freeze the game rather than do it delayed.


RE: Sequential Looping Script - AGP - 08-22-2015

Hiphiphooray!! Thank you Flawless, that worked perfectly!


RE: Sequential Looping Script - FlawlessHappiness - 08-22-2015

(08-22-2015, 07:07 PM)AGP Wrote: Hiphiphooray!! Thank you Flawless, that worked perfectly!

Aw yiss! Big Grin Great to hear!