I have this code. 2 questions.
First how can I get the "unlocked" to give me the value. Right now it spits out nil
Second why is item 2 printing before item1? How can I have it in order?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | itemList = {} itemList.item1 = {} itemList.item1.unlocked = true itemList.item2 = {} itemList.item2.unlocked = true itemList.item3 = {} itemList.item3.unlocked = true for k in pairs(itemList) do print(k) print(k.unlocked) end |
try
1 2 3 4 | for i,k in pairs(itemList) do print(k) print(k.unlocked) end |
Now I get this. Which is good but I need the name of the tables again.
table: 0x6dca60
true
table: 0x6dca80
true
table: 0x6dafb0
true
try
print(i)
Awesome. Thank you so much. I have no idea why what u said works but it does.
I guess i don't understand the" for i,k in pairs (itemList) do " expression. I understand the for loops when the i goes from say 1, 10 etc.
Thanks for your advice and time.
good to know that it worked..
in the expression "for i,k in pairs (itemList) do" i is the key and k is the value. so the expression reads as "for key,value in pairs(table) do"
Cheers...
Renjith@Technowand
my first app using corona SDK "EmoteMatch" just got approved by apple. please download to support. http://itunes.apple.com/app/id449477288?mt=8