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
0
Question by lampking · Nov 23, 2014 at 11:23 PM · arraysboo

How do I indicate that an Array is an Array?

The code below is a script intended to yield a two dimensional array. However whenever I run the code It cannot splice the arrays because it thinks that thy are objects. I've written the same code in C# and Boo but get the same error.

 import UnityEngine
 
 class Chunk_assignment (MonoBehaviour):
         count = 20
     times = 20
     def Start ():
         world = []
         line_template = []
         for y in range(0,127):
         #sets up a template that is 128 long and consists entirely of '~'#
             line_template.Add('~')
         for x in range(0,127):
         #creates an arrray, the world, that is 128 lines of the template just created#
             world.Add(line_template)
         for x in range(count):
         #Creates 20 'X's at random inside the world#
             world[Random.Range(1,len(world)-2)][Random.Range(1,len(world[0])-2)] = 'X'
         for x in range(times):
             #makes the first and last lines empty to prevent errors when expanding#
             world[0] = line_template
             world[len(world)-1] = line_template
             for x in range(0,len(world)-1):
                 world[0].Add('~')
                 world[len(world)-1].Add('~')
             linenum = 0
             for line in world:
                 newline = ['~']
                 #cleans up the vartical edges (makes all entries '~')#
                 for tilenum in range(1,len(world[linenum])-2):
                     newline.Add(world[linenum][tilenum])
                 world[linenum] = newline.Add('~')
                 linenum += 1
             linenum = 0
             for line in world:
                 tilenum = 0
                 for tile in line:
                     #planned code, currently not needed#
 #                    if tile == 'X' == world[Linenum+1][tilenum+1] == world[Linenum+1][tilenum] == world[Linenum+1][tilenum-1] == world[Linenum][tilenum+1] == world[Linenum][tilenum-1] == world[Linenum-1][tilenum+1] == world[Linenum-1][tilenum] == world[Linenum-1][tilenum-1]:
 #                        world[linenum][tilenum] = 'x'
                     if tile == 'X':
                         #for each X creates one new X near (or in) it#
                         world[linenum+Random.Range(-1,1)][tilenum+Random.Range(-1,1)] = 'X'
                     tilenum += 1
                 linenum += 1
     def Update ():
         pass
 

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 Kiwasi · Nov 23, 2014 at 11:35 PM 0
Share

You got the C# version handy? I'm having a really hard time reading Boo. You'll find far more people here that are familiar with C# then with Boo.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Eric5h5 · Nov 24, 2014 at 12:44 AM

You can't change the size of arrays. Use a generic List instead.

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 lampking · Nov 24, 2014 at 02:49 AM 0
Share

That doesn't seem to work. Even as a generic list when I put a list in a list it reverts to the object class ins$$anonymous$$d of retaining the list class.

avatar image Eric5h5 · Nov 26, 2014 at 03:48 AM 0
Share

I don't know what the syntax for generics is in Boo, but it sounds like you're using an untyped list. A generic list is declared with a specific type, so only that type can be used in it.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

When was the last update to the Unity Online Script Reference? 1 Answer

Boo Arrays & Lists 1 Answer

My array does not update when object is destroyed. How do I fix it? (java) 2 Answers

Implementing currency with gameObjects 1 Answer

creating and manipulating a grid efficiently 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