Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ethan D on Fri 03/04/2009 14:16:03

Title: Lightning not working properly
Post by: Ethan D on Fri 03/04/2009 14:16:03
I just set up the room to have lightning and it calls the script at the right times, all I need to know is how do I have it actually show the lightning.  I already have an animated background so I cant use setbackgroundframe, and I already tried using regionlighting and regiontint.  So what should I use to change the window to white momentarily?
Title: Re: Lignting wont show
Post by: Gilbert on Fri 03/04/2009 14:35:18
Hmmm is the window part of the background?

RegionTint, Lighting etc. are actually not for background effects, they actually affect characters passing those areas. Instead you may use an object or character and experiment with changing its Tint property.
Title: Re: Lignting wont show
Post by: Ethan D on Fri 03/04/2009 14:39:42
The only problem I have with doing that is that the window is animated (rain) and if its a character or object its going to be much more difficult to animate.  Although I could probably make an object that was white that fits the window and make it visible/ invisible, one question though.  How many objects can there be in a room before it causes problems. (I already have 8)
Title: Re: Lignting wont show
Post by: Gilbert on Fri 03/04/2009 14:46:40
As of V3.1.2 you can have at most 40 objects per room, so that shouldn't be a problem.
Title: Re: Lignting wont show
Post by: Ethan D on Fri 03/04/2009 15:05:56
Thanks for your help
Title: Re: Lignting wont show
Post by: Ethan D on Fri 03/04/2009 16:00:46
Alright, I had it going great with this script
  if (lightning == 2)
      {
        int RANDOM = Random(10);
        SetTimer(2, RANDOM * 24);     
        lightning = 1;
      }
      else if ((lightning == 1) && (IsTimerExpired(2) == true))
     {
      windowlightning.Visible = true;
      Wait(5);
      windowlightning.Visible = false;
      lightning = 2;
        }

But after the lightning goes several times I wait 6 seconds which should be the longest wait between lightning strikes and nothing happens.  I waited a few more minutes and its not flashing anymore lightning.  Not sure why it would stop executing.  It is under repetedly execute.
Title: Re: Lightning not working properly
Post by: ThreeOhFour on Fri 03/04/2009 16:12:22
It might be that the RANDOM variable gets set to 0, which, unless I am sorely mistaken, will disable the timer. Try recalculating the RANDOM variable whenever it gets set to 0 :).
Title: Re: Lightning not working properly
Post by: Gilbert on Fri 03/04/2009 16:16:20
The problem is, is the variable lightning initially set to 2? If not, the codes won't be executed for even the first time.
Title: Re: Lightning not working properly
Post by: Ethan D on Fri 03/04/2009 16:32:27
Thanks Ben304

Instead of changing the variable I just added a +1 to the timer so its always at least 1.
Title: Re: Lightning not working properly
Post by: ThreeOhFour on Sat 04/04/2009 04:40:08
Awww haha your solution is so much cooler and simpler than mine.

I feel like a dummy  ;D

Glad to help :D