Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: LRH on Thu 02/04/2009 00:10:27

Title: Random Lightning problem
Post by: LRH on Thu 02/04/2009 00:10:27
Hey all! I was wondering if someone can help me. I am attempting to make a random lightning event within a room.
This is the code I'm using, which I put into the room's after fadein code. What am I doing wrong? (Note, once this works, I'll replace the Display("etcetc"); with playsound and light effect for lightning.





int lightning = 1;
      if (lightning == 2)
      {
        int RAND = Random(15);
        SetTimer(1, RAND * 100);     // I've tried it without the * 100 too ...
        lightning = 1;
      }
      else if (lightning == 1 && IsTimerExpired(1) == true)
      {
        Display("Random Test!");
        lightning=2;
      }

Any help always appreciated. Thanks!
Title: Re: Random Lightning problem
Post by: Trent R on Thu 02/04/2009 03:33:25
If it's in the 'after fadr-in' code, it'll only be run once. For recurring events, use rep_exec.


~Trent
Title: Re: Random Lightning problem
Post by: LRH on Thu 02/04/2009 06:11:17
Quote from: Trent R on Thu 02/04/2009 03:33:25
If it's in the 'after fadr-in' code, it'll only be run once. For recurring events, use rep_exec.


~Trent

Thanks a lot! With that information and some minor tweaking it works great.
Title: Re: Random Lightning problem
Post by: Trent R on Thu 02/04/2009 06:14:11
Don't know if it makes a difference, but I'd move the *100 up a line, rather than putting it inside the SetTimer call.

But, it might not even matter.

~Trent