none
Error CS1513 RRS feed

  • Question

  • I have been working on finding the errors it says i have and i just cant see them. Here is my code where the errors are. 

    public class StoneLoretta_Week2Project : MonoBehaviour
    {
        Text screen;
        Page[] book;

        [SerializeField]
        string prevHeading;
         [SerializeField]
        string currHeading;
        [SerializeField]
        string nextHeading = "wake up";

        public string PrevHeading { get => prevHeading; set => prevHeading = value; }

        // Use this for initialization
        void Start()
        {
            GameObject go = GameObject.Find("MainText");

            if (go) ;
            {
                screen = go.GetComponent<Text>();

                if (!screen)
                {
                    Debug.LogError("Text Component was not found on MainText");
                }
            }
            else
            {
                    Debug.LogError("mainText not found");
            }

        }
                else if (Input.GetKeyDown(KeyCode.H))
                {
                    if (currHeading == "break the window" || currHeading == "try the phone") 
                    {
                        nextHeading = "find a highway";
                    }
                }
                else if (Input.GetKeyDown(KeyCode.X))
                {
                    nextHeading = PrevHeading;

                }
            }
            else
            {
                if (currHeading == "wake up" || currHeading == "check the car" || currHeading == "break the window") ;
                {
                    nextHeading = "check the farmhouse";
             }
                else if (currHeading == "enter the farmhouse")
                {
                    ;
                }
            }

        }
    }

    Saturday, April 13, 2019 3:45 AM

All replies

  • I see at least one error; there could be more:

            if (go) ;
            {
                ...
            }

    There is a superfluous semicolon after the (go).

    There are also some mismatched braces. The brace after the first else block appears to close the void start method, but there is code below which should belong to the method.

    When you post in the forums, it is not a good idea to just say "I have errors". You should copy the exact wording of the errors and indicate in which line each error happens. Otherwise it is quite difficult to infer what the errors are and where they are by just taking a look at the code.

    Saturday, April 13, 2019 9:01 AM
    Moderator
  • Also, if (go) isn't correct just on it's own. go is an instance of GameObject and I assume what you really meant to check was that it wasn't null, in which case you need it to be:

    if (go != null)

    And, I agree fully with Alberto … always post information about the what the wording of the error actually is and which line it occurs on.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Sunday, April 14, 2019 12:37 AM
    Moderator
  • Hi

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 7, 2019 8:11 AM
    Moderator