'parse error at 'else'

Started by blenderhead, Mon 30/09/2013 00:57:20

Previous topic - Next topic

blenderhead

Code: ags
// room script file

function hHotspot1_AnyClick()
{

   if (code == 0) code++;
 
   
  else code = 0;
}

function hHotspot2_AnyClick()
{
   if (code == 1) code++;
 beef.Visible=true;
   
  else code = 0;
}

}


I'm still a beginner with code and can't see why this doesn't work.
clicking on hotspot2 only after clicking on hotspot1 should have the object(beef) visible, yet i'm getting a 'parse error at 'else'' error at the second 'else'
it seems to work fine with out the 'beef.Visible=true;' line.

Khris

You need to use braces if you want to call more than one command depending on the outcome of a check:
Code: ags
function hHotspot2_AnyClick()
{
  if (code == 1)
  {
    code++;
    beef.Visible=true;
  }
  else code = 0;
}

blenderhead

Thanks Khris, problem solved. :)

SMF spam blocked by CleanTalk