Windows Unexpected unary operator = (Solved)

Discussion in 'GameMaker Studio 2 Community Tech Support' started by GDevEric, Jan 11, 2020.

  1. GDevEric

    GDevEric Member

    Joined:
    Jan 11, 2020
    Posts:
    2
    Hi I'm new to GMS2. I was watching this tutorial video at around 8:35 I had to stop because of this warning which prevented me from running the game.
    upload_2020-1-11_14-13-30.png
    I have no idea what i did wrong and don't know how to progress.
     

    Attached Files:

  2. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,191
    I believe you just need a space between the five and the negative sign (possibly also the plus). In general, you should use spaces around your operators (+, -, and so on) but it normally won't cause problems. Here though, because - is both minus and negative, the lack of spaces means it is interpreted as a negative sign making that line a bad line of code.

    You're also missing parenthesis after the if statement. And you should be using brackets and at least indenting after them as well. You can safely exclude brackets for only a single line, but you should still indent. It will make your code more readable and prevent unintentional errors.

    I think all three of the issues I see here are caused by not following some basic code formatting guidelines, which in this case have actually caused errors. I would pay more attention to the actual style and formatting techniques Friendly Cosmonaut uses in these tutorials and try to follow those as well.
     
  3. xDGameStudios

    xDGameStudios Member

    Joined:
    Sep 15, 2016
    Posts:
    593
    This shouldn’t raise a parser error!! Strange! Try formatting or code correctly, adding braces and parentheses to the if statements
     
  4. kraifpatrik

    kraifpatrik Member

    Joined:
    Jun 23, 2016
    Posts:
    145
    You forgot to put closing ) after the if condition

    EDIT: Too late
     
    Last edited: Jan 11, 2020
  5. GDevEric

    GDevEric Member

    Joined:
    Jan 11, 2020
    Posts:
    2
    Okay I added the spaces and parentheses and the warnings went away. I'll make sure to keep a closer eye on the formatting. Thanks guys
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice