Hey everyone,
I’ve a weird problem. I have a main array that holds items, and within that array I have an additional array for each item (so an array in an array).
When I do a regular loop to go through the items in the main array, it doesn’t loop in order. It does a random order instead. I want to loop through the secondary arrays in the order they were inserted into the main array.
Example:
mainArray = {
item1 = {name = "Hammer" , cost = 100, imgName = "Hammer.png"},
item2 = {name = "Sword" , cost = 500, imgName = "Sword.png"},
item3 = {name = "Gun" , cost = 1000, imgName = "Gun.png"},
}
This is not my actual code, but it show what I’m doing. I have around 12 items inserted into the main array, and then when looping through the main array and retrieving each secondary array, they don’t come in the correct order.
Any suggestions?
PS. I’m looping through using some code like this:
[code]
for i,value in pairs(mainArray) do
end
[/code] [import]uid: 51654 topic_id: 16395 reply_id: 316395[/import]
[import]uid: 3826 topic_id: 16395 reply_id: 61214[/import]