Can you include object and buttons in if statements?

Started by shaungaryevans, Mon 20/04/2009 21:37:13

Previous topic - Next topic

shaungaryevans

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?

GarageGothic

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:

Code: ags
if (bad6.Visible == false) {

JpSoft

#2
This is an error i had a lot when i started using AGS (and even now), since i usually work in Delphi, where
Code: ags
" = "
is to compare and
Code: ags
" := "
to assign values. We are lucky that AGS have a great debug tool.

Jp

shaungaryevans


SMF spam blocked by CleanTalk