8 Dimensions Rendered
- ishkabible
- Party member
- Posts: 241
- Joined: Sat Oct 23, 2010 7:34 pm
- Location: Kansas USA
Re: 8 Dimensions Rendered
i thought ipairs only traversed the array part, e.g. it's already ordered in an arrary
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: 8 Dimensions Rendered
If I have this correct, a table like:
table[1]
table[2]
table[3]
table[6]
table["words"]
Will be traversed from 1 to "words" when using pairs(), but only up to 3 if using ipairs(). I believe?
table[1]
table[2]
table[3]
table[6]
table["words"]
Will be traversed from 1 to "words" when using pairs(), but only up to 3 if using ipairs(). I believe?
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: 8 Dimensions Rendered
The order of traversal when using pairs is not guaranteed, but yes, you're correct.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: 8 Dimensions Rendered
Explain. Is there a way to know exactly what order they'll go through? I thought it would go in the order the table row was added. Especially if it uses a string instead of a number. And that you can use table.sort to order them for more predictable run through. At least that's what I count on when I use table.sort for my top-down engines to keep "front" objects in front of "back" ones.slime wrote:The order of traversal when using pairs is not guaranteed, but yes, you're correct.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: 8 Dimensions Rendered
http://lua-users.org/wiki/ForTutorial
You can guarantee the order by sticking the keys into an array, sorting the array, and then accessing the values by the ordered keys.Lua provides a pairs() function to create the explist information for us to iterate over a table. The pairs() function will allow iteration over key-value pairs. Note that the order that items are returned is not defined, not even for indexed tables.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: 8 Dimensions Rendered
New version! Several new little tweaks to make it a bit more user friendly.
Kurosuke needs beta testers
Who is online
Users browsing this forum: No registered users and 6 guests