Perhaps I've just been thinking about this the wrong way, but I've looked over a bunch of material and can't find quite what I'm looking for.
I have defined variables in a script.
apple = 0
banana = 0
cranberry = 0
I have also defined a table with these variables' names contained in it.
fruittable = { "apple", "banana", "cranberry" }
I want to write a function that will take all of the string entries in a table, and use these strings to set the variables (of the same names) equal to 1. I know how to iterate with pairs() and ipairs, so the crux of my question is, how do I use the string returned by fruittable[1] (which is apple) to set a value for the variable of the same name?
Edit: I'm well aware that all the functionality I'm looking for is available in tables defined like the below, instead. In fact that's what I'm doing now, but after the time I spent trying to figure out how to do what I mentioned above I really want to know if it's possible.
fruittable = { apple=0, banana=0, cranberry=0 }