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...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With