Help with "else" statement (SOLVED)

Started by Tomatoworm, Mon 08/10/2012 18:12:49

Previous topic - Next topic

Tomatoworm

Hello,
I have been trying to use the else statement when I use an inventory item on a object ,but I keep getting "unexpected else" error. I'am trying to make it where only one inventory item works.
Here is the script:
function Painting_UseInv()
{
  if (cBert.ActiveInventory == iPscraper)
  cBert.Walk(445, 218, eBlock, eWalkableAreas);
  cBert.FaceObject(Painting);
  Painting.Visible = false;
  PaintingSide.Visible = true;
  RemoveWalkableArea(4);
}
  else{
  cBert.Walk(445, 218, eBlock, eWalkableAreas);
  Display("This won't work");
}

Has anyone else had this problem?

geork

Put a bracket behind the "if" clause, and remember to finish the whole function with a bracket
Code: AGS

function Painting_UseInv()
{
  if (cBert.ActiveInventory == iPscraper){ //this is where the bracket was missing
  //stuff
  }
  else{
  //other stuff
  }
}//to close the function


That should do it :)

Tomatoworm

That was it!I keep on forgetting about the closing braces. Thank for for you reply! :-D

SMF spam blocked by CleanTalk