PE04: parse error When trying to Switch Object graphics

Started by MegzHeartcho, Thu 12/03/2009 04:28:38

Previous topic - Next topic

MegzHeartcho

I know I made a post similar to this already but now I'm running into a serious error and I don't know how to fix it. ???

What I'm trying to do is change the graphics of an object depending on the objects current graphic and if the player interacts with it.

Here's an example of the situation and the code that's giving the error:

When the player interacts with the closed door, the graphic changes so it opens.

Code: ags

function oSafedoor_Interact()
{
if (oSafedoor.Graphic == 9) {
    oSafedoor.Graphic == 8;
  }

}


I keep getting an error saying "Error (line 17): PE04: parse error at 'oSafedoor'" which is the line that reads "oSafedoor.Graphic == 8;".

I've tried changing the name and such but it keeps not letting me save with the line of code or run the game.

Any help you can offer me will be greatly appeciated.

GarageGothic

You use "==" for comparing values and "=" for setting them, so your code should be:

Code: ags
function oSafedoor_Interact() {
  if (oSafedoor.Graphic == 9) {
    oSafedoor.Graphic = 8;
    }
  }

MegzHeartcho

Quote from: GarageGothic on Thu 12/03/2009 04:38:21
You use "==" for comparing values and "=" for setting them, so your code should be:

Code: ags
function oSafedoor_Interact() {
  if (oSafedoor.Graphic == 9) {
    oSafedoor.Graphic = 8;
    }
  }


:o Oh my goodness, it worked. Thank you so very much.  ;D

SMF spam blocked by CleanTalk