I have three tables. One with integers, one with strings, and one that is empty. All three tables are filled automatically. Once the first two tables are filled (both having equal entries) I want the third table to fill itself where each entry's key is the value from table 'a' and each entry's value is the value from table 'b'. Table 'a' will always have unique values. I'm new to lua so please be as specific as possible.
Example:
a = {"joe", "bob", "bill"}
b = {"24", "111", "32"}
c = {joe = "24", bob = "111", bill = "32"}
My current tables are created like this:
a = {}
b = {}
c = {}
functionThatPopulatesTableA()
end
for i, #a do
b[i] = functionThatReturnsSpecificValue()
end
My attempt to fill table c ended up looking like this:
function charlie()
for k, v in pairs(a) do
c[v] = a[v]
c[k] = b[v]
end
end
Needless to say, that did not work.
function charlie() for k, v in pairs(a) do c[k] = a[v] c[v] = b[k] end endAnd it works?? Why does this work? table 'b' should only have values, and indices as keys right? So table 'b' keys should be 1, 2, ... Yet when I use c[v] = b[k] it returns b's value as if it's b's key - Nick