Reputation: 39467
I know this seems like a dumb question but how do I search a lua table for a given item? let's say I have a table like this:
local table = { itemA = 0.8, itemB = 1.2, itemC = 1 }
Is there, say, a function named table.find
or something? It's also late here so I'm not thinking too clearly at the moment...
Upvotes: 7
Views: 12092
Reputation: 24180
You can lookup items in the table either using the []
operator:
x=table["itemA"]
or by using the .
operator:
x=table.itemA
Edited because original code is now syntax-correct.
Upvotes: 8