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 » Scripters
Home Search
 

Equals 0??

Previous Thread :: Next Thread 
Twistir is not online. Twistir
Joined: 19 Nov 2009
Total Posts: 12374
25 Jan 2015 12:11 AM
This is suppose to print how many items are in the table, but it prints 0. What is wrong?

shirtids = {
s1 = {textureid=200029202,thumbid=200029204,cost=200},
s2 = {textureid=200029202,thumbid=200029204,cost=200},
s3 = {textureid=200029202,thumbid=200029204,cost=200},
s4 = {textureid=200029202,thumbid=200029204,cost=200},
s5 = {textureid=200029202,thumbid=200029204,cost=200},
}

print(#shirtids)





Report Abuse
Ojia is not online. Ojia
Joined: 08 Feb 2012
Total Posts: 650
25 Jan 2015 12:18 AM
I think its confused because there's multiple tables in tables
Report Abuse
SaluteMeScrub is not online. SaluteMeScrub
Joined: 28 Dec 2013
Total Posts: 380
25 Jan 2015 12:20 AM
You can't have a table in a table.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
25 Jan 2015 12:21 AM
its no longer a table

http://wiki.roblox.com/index.php?title=Dictionary#Dictionaries
Report Abuse
Twistir is not online. Twistir
Joined: 19 Nov 2009
Total Posts: 12374
25 Jan 2015 12:26 AM
How can i fix it?
Report Abuse
Ojia is not online. Ojia
Joined: 08 Feb 2012
Total Posts: 650
25 Jan 2015 12:29 AM
Try doing print(shirtids) instead
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
25 Jan 2015 12:31 AM
something like this:

local count = 0
for i,v in pairs(shirtids)do
count = count + 1
print(count)
end

thats not a very good one but ill leave it to you to refine it
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
25 Jan 2015 01:09 AM
The # operator doesn't work with dictionaries, only with standard tables, which have numeric keys. You'll need to write a custom function to retrieve the amount of values inside.

function _(t)
i=0; k,v = next(t,nil);
while k do
i = i+1;
p = k;
k,v = next(t,p);
end;
end;

USAGE :

print(_(shirtids));


::_::goto_
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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