Jump to content

Can't get array length or loop it [solved]


Yazir

Recommended Posts

Hello! I have a problem. I wanted to ipair a table but it won't go through indexes. Made some debug outputs and these are the code and the result:

	buildingClasses = { ["Residential"] = {
{"Soda Can (Mountain Dew)",2405,2,0,0.28},
{"Watch",2710,2,0,4.20},
{"Compass",1579,2,0,1.40},
{"Map",1277,3,0,0.84},
{"Double-barreled Shotgun",349,1,90,0.84},
{"test",349,1,90,0.84},
},
}
	
outputChatBox(type(buildingClasses))
outputChatBox(table.getn(buildingClasses))
outputChatBox(#buildingClasses)
outputChatBox(#buildingClasses["Residential"])
outputChatBox(#buildingClasses["Residential"][1])


--[[ 
Output:
table
0
0
6
5
]]

Got the issue: I've used ipairs instead of pairs

Edited by Yazir
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...