Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-1
Question by Owen Swick · May 13, 2011 at 06:09 PM · syntax-errorbce0044eof

BCE0044: expecting }, found 'class' alond with BCE0044: expecting EOF, found 'Card'

I am going through a Unity3d book for beginners and I came accross something that I can't figure out. I recieve 2 errors when trying to run my game -

BCE0044: expecting }, found 'class' alond with BCE0044: expecting EOF, found 'Card'

Here is my script -

var cols:int = 4; var rows:int = 4; var totalCards:int = cols*rows; var matchesNeededTOWin:int = totalCards * 0.5; var matchesMade:int = 0; var cardW:int = 100; var cardH:int = 100; var aCards:Array; var aGrid:Array; var aCardsFlipped:ArrayList; var playerCanClick:boolean; var playerHasWon:boolean = false;

function Start () { playerCanClick = true; acards = new Array(); aGrid = new Array(); aCardsFlipped = new ArrayList();

     BuildDeck();

     for(i=0; i<rows; i++)
 {
     aGrid[i] =  new Array() ; 

     for (j=0; j<cols; j++)
     {
         var someNum:int = Random.Range(0,aCards.length);
         aGrid[i] [j] = aCards[someNum];
         aCards.RemoveAt(someNum);
     }
 }

}

function OnGUI () { GUILayout.BeginArea (Rect (0,0,Screen.width,Screen.height)); BuildGrid(); GUILayout.EndArea(); print("building grid!"); }

function BuildGrid() { GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); for(i=0; i<rows; i++) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); for(j=0; j<cols; j++) { var card:Object = aGrid[i] [j]; if(GUILayout.Button(Resources.Load(card.img), GUILayout.Width(cardW))) { Debug.Log(card.img); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); }

function BuildDeck() { var totalRobots:int = 4; var card:Object; for (i=0; i<totalRobots; i++) { var aRobotParts:Array = ["Head", "Arm", "Leg"]; for (j=0; j<2; j++) { var someNum:int = Random.Range(0, aRobotParts.length); var theMissingPart:String = aRobotParts [someNum];

     aRobotParts.RemoveAt(someNum);

     card = new Card("robot" + (i+1) + "Missing" + theMissingPart);
     aCards.Add(card);

     card= new Card("robot" + (i+1) + theMissingPart);
     aCards.Add(card);
 }

}

class Card extends System.Object { var isFaceUp:boolean = false; var isMatched:boolean = false; var img:String;

 function Card()
 {
     this.img = img;
 }   

}

From what I have read on other posts I either have to many '}' or not enough, but I don't think that is the case here since I have 2 open and 2 closing.

If I could get some help with this I would appreciate it very much!

Thanks

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image almo · May 13, 2011 at 06:44 PM 0
Share

You can preview your posts here. So when you post a new question, make sure the code blocks are done right. You should edit it so that the code block is correct; it's easier for people to see what's going on then.

avatar image yoyo · May 13, 2011 at 06:48 PM 2
Share

(I reformatted the code for you -- use the 01 icon for this.) The code shown looks fine -- is there something else in the file before the word "class"? What file extension does your script have?

avatar image GesterX · May 13, 2011 at 06:59 PM 0
Share

Is this the entire script?

avatar image Owen Swick · May 13, 2011 at 07:14 PM 0
Share

Thank you for editing the format for me almo.

I was going to post my whole scropt but it looks all funny like the last time I copied and pasted it. How do you make it look correct on the post? Sorry this is the first question I have posted. I will post the whole script as soon as I can post it with the correct format. Thanks for your help - almo, yoyo, and GesterX

avatar image DaveA · May 13, 2011 at 11:44 PM 1
Share

On $$anonymous$$e, the code button looks like 010 and 101 on two lines.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by GesterX · May 15, 2011 at 05:10 PM

You need an additional curly bracket at the end of your BuildDeck function...

function BuildDeck() { var totalRobots:int = 4; var card:Object; for (i=0; i<totalRobots; i++) { var aRobotParts:Array = ["Head", "Arm", "Leg"]; for (j=0; j<2; j++) { var someNum:int = Random.Range(0, aRobotParts.length); var theMissingPart:String = aRobotParts [someNum];

     aRobotParts.RemoveAt(someNum);

     card = new Card("robot" + (i+1) + "Missing" + theMissingPart);
     aCards.Add(card);

     card= new Card("robot" + (i+1) + theMissingPart);
     aCards.Add(card);
    }
 }

}

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Owen Swick · May 16, 2011 at 11:42 AM 0
Share

Thank you GesterX this works perfect now.

avatar image GesterX · May 16, 2011 at 12:34 PM 0
Share

No worries. Glad to help.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

sript gets error 2 Answers

An EOF Problem :( 1 Answer

EOF error message 2 Answers

An EOF Problem :( (New) 3 Answers

script error GUI super simple code 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges