Search Unity

FIXED So why I am stuck with this wierd problem in MonoDevelop?

Discussion in 'Scripting' started by Notarmaso, Nov 21, 2014.

  1. Notarmaso

    Notarmaso

    Joined:
    Oct 1, 2013
    Posts:
    13
    Attachment related (picture of the simple code). I says that there's a unexpected symbol and a phrasing error. When I'm almost sure that there isn't.

    Thanks for the help!

    /Notarmaso
     

    Attached Files:

  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Try fixing your indentation — currently it's all over the place, which makes it very hard to see where you are missing a curly brace (or have an extra one). Use the Edit > Format > Format Document command.

    HTH,
    - Joe
     
  3. Notarmaso

    Notarmaso

    Joined:
    Oct 1, 2013
    Posts:
    13

    Nothing really happened when i used the Format Document command.
    Any other ideas?

    Thanks again.
     

    Attached Files:

  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    Review your fundamentals of data types in C#. First problem is the doorIsOpen variable. That is a float. You can compare it with another float to end up with a true/false condition. For example, where you say if (doorIsOpen), that is not valid. You could perhaps say if (doorIsOpen > 0) for instance, or else if (doorIsOpen != 0).

    C# enforces this sort of strictness much more than C or C++. It is in the end a GoodThing(tm) because it forces the programmer to more clearly state his intent before code is accepted for compilation. It's not a panacea, and it may drive you nuts at first, but overall its a good thing.
     
  5. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    You're missing a semicolon at the end of the line 45.
     
    Notarmaso likes this.
  6. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    That's weird. Hmm. Well, fix the indentation manually if you have to. Any lines after a { should be indented. A } and any lines after it should be outdented.

    Seriously... friends don't let friends use incorrectly-indented code.

    (Also, @shaderop is right, the missing semicolon is probably causing the current error.)
     
  7. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Friends also don't let friends use MonoDevelop on Windows :)
    I seriously can't believe the IDE isn't catching that.
     
    Suddoha and JoeStrout like this.
  8. Notarmaso

    Notarmaso

    Joined:
    Oct 1, 2013
    Posts:
    13
    I looooove you!
    Everything is fixed now.

    Thanks to you all!