Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: shaungaryevans on Mon 20/04/2009 21:37:13

Title: Can you include object and buttons in if statements?
Post by: shaungaryevans on Mon 20/04/2009 21:37:13
I doing a code like this:

function welldone_OnClick(GUI *theGui, MouseButton button)
{
if (bad6.Visible = false){                                           line 718
  digipad_1.Visible = false;
  welldone.Visible = true;
}

bad6 is the name of a button

but it say,
GlobalScript.asc(718): Error (line 718): Parse error in expr near 'bad6'


Can somebody tell me why this is happening and how to solve it please?
Title: Re: Can you include object and buttons in if statements?
Post by: GarageGothic on Mon 20/04/2009 21:48:09
It's because you're using a single "=" instead of "==" in the if statement. "==" is used for comparing values, "=" for setting them.

It should be:

if (bad6.Visible == false) {
Title: Re: Can you include object and buttons in if statements?
Post by: JpSoft on Mon 20/04/2009 21:59:16
This is an error i had a lot when i started using AGS (and even now), since i usually work in Delphi, where " = " is to compare and " := " to assign values. We are lucky that AGS have a great debug tool.

Jp
Title: Re: Can you include object and buttons in if statements?
Post by: shaungaryevans on Mon 20/04/2009 22:07:28
Thanks for, thats really helpful  :)