8 Dimensions Rendered

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
ishkabible
Party member
Posts: 241
Joined: Sat Oct 23, 2010 7:34 pm
Location: Kansas USA

Re: 8 Dimensions Rendered

Post by ishkabible »

i thought ipairs only traversed the array part, e.g. it's already ordered in an arrary
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: 8 Dimensions Rendered

Post by Jasoco »

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?
User avatar
slime
Solid Snayke
Posts: 3134
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: 8 Dimensions Rendered

Post by slime »

The order of traversal when using pairs is not guaranteed, but yes, you're correct.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: 8 Dimensions Rendered

Post by Jasoco »

slime wrote:The order of traversal when using pairs is not guaranteed, but yes, you're correct.
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.
User avatar
slime
Solid Snayke
Posts: 3134
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: 8 Dimensions Rendered

Post by slime »

http://lua-users.org/wiki/ForTutorial
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.
You can guarantee the order by sticking the keys into an array, sorting the array, and then accessing the values by the ordered keys.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: 8 Dimensions Rendered

Post by tentus »

New version! Several new little tweaks to make it a bit more user friendly.
Kurosuke needs beta testers
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 61 guests