generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Another Array Question

Previous Thread :: Next Thread 
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
18 May 2013 05:24 PM
--Say I have these tables
local array = {1, "string", Workspace.Part}
local array2 = {2. "anotherstring", Workspace.OtherPart}
--Using these for loops
for i, v in pairs(array) do
print(v)
for i, v in pairs(array2) do
print(v)
end
end
--Would that not print the two tables?
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
18 May 2013 05:25 PM
It would not because the two loops are inside of one another and share variable names.

~ Linguam latinam est optimum ~
Report Abuse
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
18 May 2013 05:26 PM
*facepalm*
I could just change the names, couldn't I?

Dumb question.
Report Abuse
justin2865 is not online. justin2865
Joined: 30 Dec 2011
Total Posts: 4677
18 May 2013 05:27 PM
--Say I have these tables
local array = {1, "string", Workspace.Part}
local array2 = {2. "anotherstring", Workspace.OtherPart}
--Using these for loops
for i, v in pairs(array) do
print(v)
end
for i, v in pairs(array2) do
print(v)
end
--Would that not print the two tables?
Report Abuse
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
18 May 2013 05:27 PM
Well, when you have objects in a table that aren't stringvalues, printing them would produce bytes or some other unidentifiable anomaly. You can't print a part, can you?

Now, the number and the string can be printed, but if you want the whole table to be legible, try Workspace.Part.Name instead.

Also, make sure to end each 'for' loop before starting a new one.
Report Abuse
justin2865 is not online. justin2865
Joined: 30 Dec 2011
Total Posts: 4677
18 May 2013 05:29 PM
Oops, I never looked at the tables. You wouldn't be able to do that.

Report Abuse
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
18 May 2013 05:29 PM
I tried doing print(Workspace.Part) and it printed the name. I don't know why.
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
18 May 2013 05:30 PM
Actually, when print is called on an instance it prints the part's full name, as given by Instance::GetFullName()

~ Linguam latinam est optimum ~
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
18 May 2013 05:30 PM
Derp. That's a different function. It prints the name...

~ Linguam latinam est optimum ~
Report Abuse
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
18 May 2013 05:36 PM
From my experience, printing an instance prints its name.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image