DarkLink Posted July 24, 2011 Share Posted July 24, 2011 Guys is there a way to stop looping a table? I mean the table have 10 elements, but I just want to loop the table for the first five, the other five wont get loaded, just ignored. Appreciate some help guys. Thanks. Link to comment
Buffalo Posted July 24, 2011 Share Posted July 24, 2011 for i=1,10 do if i == 5 then break end end Link to comment
DarkLink Posted July 24, 2011 Author Share Posted July 24, 2011 thanks for ur reply, but look this: for i,k in ipairs (getElementsByType("vehicle")) do -- how do I do what is here only for the first five cars, when reach the six exit for or do nothing.. end Thanks buffalo. Link to comment
JR10 Posted July 24, 2011 Share Posted July 24, 2011 for i,k in ipairs (getElementsByType("vehicle")) do if i == 5 then break end end Link to comment
DarkLink Posted July 24, 2011 Author Share Posted July 24, 2011 for i,k in ipairs (getElementsByType("vehicle")) do if i == 5 then break end end Hmm I see so break is used to leave the for that is inside, right? Thanks. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now