Table > how to pick or skip values?
hi,
I've searched for a few hours in vain here and on the web but I fail to pick the proper keywords to find the answer for my question. Lua Code:
will print: test1 test2 test3 but what if I want to print: test1 test2 test4 test5 how to skip a value? or pick only a few that are not consecutive? like for: test2 test5 |
As with any array you either get them in order ..
Lua Code:
or select them by index Lua Code:
or select them by key if they are not in sequential index order Lua Code:
If you want to go through a list and print certain ones you will need an additional check, using some set of if statements that will tell you if that item is the one that fits the bill. In this example the items table contains a class name to signify that item is for priests only. So if you want to print off all those items suitable for priests then you would do that test. How you would use this all depends on what information your data includes. Lua Code:
https://www.lua.org/pil/2.5.html |
thank you, I'll look into it.
|
For further practice on working with tables, see here:
http://lua-users.org/wiki/TablesTutorial (basic) http://lua-users.org/wiki/TableLibraryTutorial (a little more advanced) |
All times are GMT -6. The time now is 04:09 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI