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 Gamer_Assassin · May 04, 2014 at 04:43 AM · javascriptnewbiebce0044

I'm new to coding. BCE0044 error. How do I fix? When I delete the extra } it gives me 23 errors

 var cols:int = 4;
 var rows:int = 4;
 var totalCards:int = 16;
 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();
     for(i=0; i<rows; i++)
     {
     aGrid[i] = new Array();
     for(j=0; j<cols; j++)
     {
     aGrid[i][j] = new Card();
     }
     }
 }
 
 function BuildGrid()
 {
     GUILayout.BeginVertical();
     for(i=0; i<rows; i++)
     {
         GUILayout.BeginHorizontal();
         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.EndHorizontal();
     }
         GUILayout.EndVertical();
     }
     }
 
 function OnGUI()
 {
     GUILayout.BeginArea (Rect(0,0,Screen.width,Screen.height));
     BuildGrid();
     GUILayout.EndArea();
     print("building grid!");
 }
 
 class Card extends System.Object
     {
         var isFaceUp:boolean = false;
         var isMatched:boolean = false;
         var img:String;
         function Card()
         {
             img = "robot";
         }
     }
Comment
Add comment · Show 1
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 Benproductions1 · May 04, 2014 at 07:22 AM 0
Share

Please provide more information. You've only posted a piece of code, how are we supposed to help you?

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ReZo · May 04, 2014 at 08:46 AM

I can go ahead and tell that you are working out of one of the Unity books (One that I remember doing in one of my past classes in college)

If I am not mistaken, this is a snippet of code from the "Robot Repair" chapters.

The finished code is in the book

I recommend you sit down with the book, and make sure you have it typed out exactly the same way he typed it.

He gives step by step instructions on how to set it up.

Read slow, and make sure to do everything he does in the book

Proof: I went through the book and completed this very project

Comment
Add comment · 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
0

Answer by Ikannuna · May 04, 2014 at 08:34 AM

Remove the extra }

and add "var" infront of the variable in the forloops

  for(var i=0; i < rows; i++)
     {
         aGrid[i] = new Array();
         for(var j=0; j < cols; j++)
         {
             aGrid[i][j] = new Card();
         }
     }
Comment
Add comment · 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
0

Answer by bloodyatheist · May 04, 2014 at 09:28 AM

you got a redundant } in line 51 delete it save and it will work

and in a for loop you should add var.

just replace your start and BuildGrid functions with that:

 function Start() 
 {
     playerCanClick = true;
     aCards = new Array();
     aGrid = new Array();
     aCardsFlipped = new ArrayList();
     for(var i=0; i<rows; i++)
     {
         aGrid[i] = new Array();
         for(var j=0; j<cols; j++)
         {
             aGrid[i][j] = new Card();
         }
     }
 }
  
 function BuildGrid()
 {
     GUILayout.BeginVertical();
     for(var i=0; i<rows; i++)
     {
         GUILayout.BeginHorizontal();
         for(var 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.EndHorizontal();
     }
     GUILayout.EndVertical();
 }



and a tip for the new developer :

if you got more errors after fixing an error it doesn't mean that you did something wrong when the program(its called compiler) is trying to run your code it does several checks on your code so if you got wrong parentheses placement the compiler won't check your code any further (so after you fix it it will do more checks on your code and find more errors if there are any)

parentheses checks are one of the the first ones so if you don't see them than they are usually fine

good luck with the new hobby :)

Comment
Add comment · Show 1 · 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 Gamer_Assassin · May 04, 2014 at 10:53 PM 0
Share

Thanks lkannuna & bloodyatheist. Cleared all errors

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

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

JavaScript Syntax and Punctuation Meanings Question 1 Answer

How to use if statement with var? 3 Answers

Atmosphere sounds triggered by invisible blocks? (JS) 1 Answer

Making a pick up item that is timed, that moves,scales and rotates 1 Answer

Declaring myRigidbody 1 Answer


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