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;
}
}
}
}
}
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.
Alright. I think I'm satisfied.