Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Dualnames on Fri 06/01/2012 23:49:17

Title: Overlay Question (SOLVED)
Post by: Dualnames on Fri 06/01/2012 23:49:17
I want to run something by you guys. I'm using the code below for an overlay thingie.
So I'm running this code on a repeatedly execute always. Start and yaah are just two booleans initially set to false.

Initially the game threw me a error:ScriptOverlay isn't there. So I'm wondering is checking if an Overlay is null and then if it's Valid the best way to make sure, that I don't get the error?



function repeatedly_execute_always()
{


if (start==true)
{
   if (yaah==true)
   {
      bgspeech = Overlay.CreateTextual(cCrispin.x-GetViewportX()-(getheight.Width),  cCrispin.y+25-(getheight.Height), 255, eFontSpeech, cCrispin.SpeechColor,
   }
   if (yaah==false)
   {
      if (bgspeech!=null)
      {
         if (bgspeech.Valid)
         {
            bgspeech.Remove();
            start=false;
         }
     }
  }
}

}
Title: Re: Overlay Question
Post by: Khris on Sat 07/01/2012 02:04:30
Yes, you can do it one go though:

  if (bgspeech && bgspeech.Valid)

AGS will evaluate the condition from left to right and thus shouldn't throw a null pointer error.
Title: Re: Overlay Question
Post by: Dualnames on Sat 07/01/2012 04:10:21
Alright. I think I'm satisfied.