lua - How to iterate from last index to first in table -


bestsword = {   {name = 'www' , lvl = 35, atk = 38, npcprice = 15000 , buyprice = 0},   {name = 'bbb' , lvl = 40, atk = 40, npcprice = 20000 , buyprice = 0},   {name = 'eee' , lvl = 50, atk = 42, npcprice = 25000 , buyprice = 0},   {name = 'sss' , lvl = 55, atk = 43, npcprice = 30000 , buyprice = 0},   {name = 'aaa' , lvl = 60, atk = 44, npcprice = 30000 , buyprice = 0},   {name = 'qwe' , lvl = 70, atk = 46, npcprice = 35000 , buyprice = 0},   {name = 'asd' , lvl = 82, atk = 48, npcprice = 60000 , buyprice = 0} } 

i have table, how can iterate last index first? should break depends lvl. want show table best weapon. example if player have level 53, want show weapons lvl or lower. need show best 1 (at top) why want iterate last index. help?

edit: help. there still problem need changed table later. shows fine need buy litems (changed) list later. must replace in way 2 tables. there easy way that? tried remove elements table still not works.

or possible make map in lua? must dynamic sized cant use table guess. key - value

a numeric loop, counting down, best option:

local t = {2,4,6,8}  = #t, 1, -1     print(t[i]) end 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -