Hero192 Posted July 27, 2015 Share Posted July 27, 2015 Hey guys, i have some questions, i want to knows what does these variables do and when we can use them (i didnt understand the meaning of them from lua.org),i'll like to hear that from some experienced scripters Break while untill Link to comment
GTX Posted July 27, 2015 Share Posted July 27, 2015 You can use break to break a loop. for i=1, 10 do if i == 5 then break -- Breaks loop, doesn't go on. end end While is like a loop which repeats process until the condition is true. while true do end -- Or: local i = 1 while i <= 10 do i = i + 1 -- Goes until 10 end Until is used with repeat like: local i = 1 repeat -- Repeats step until desired value or true i = i + 1 until i == 10 -- Stops when it's 10 Link to comment
Hero192 Posted July 27, 2015 Author Share Posted July 27, 2015 Thanks i understand your messages,i have one more question, what's the diferrent between pairs and ipairs Link to comment
Buffalo Posted July 27, 2015 Share Posted July 27, 2015 Ipairs goes thru table containing number indexes in the row. Any other would be skipped. If your table is indexed number by number you should use ipairs. But if table contains number indexes 1,2,3,4,6 ipairs will stop at 4, then you must use pairs which is lil bit slower. Link to comment
GTX Posted July 27, 2015 Share Posted July 27, 2015 From my point of view: Pairs gives a general iterator over all the keys and values in the table, numerical or not, in no particular order, meanwhile ipairs goes over the array part, in order. Therefore pairs is faster. 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