Ok, here's the problem. I want to store dynamically a sequence of values in a table i already have created. The idea is to make a standard function that updates these variables without defining them one by one - until now i had like 2-3 of them, now we're talking about 40-50.
What i have and can use? I have a list = {a, b, c, d} which is already defined, i want to do a method to create new fields in a "database" called with the names in that list.
The method should look like this:
so the result should be something likeCode:function storevalues() for _, v in pairs(list) do local db = "my database" fieldname = _G[v] -- create the field called db.fieldname if somekindofcondition then db.fieldname = true else db.fieldname = false end end
Making manually a variable for every value i need to store isn't an option, since i can even make it, but if i change something i'd need to double-check every one.Code:db.a = true db.b = false db.c = true db.d =true