How can I assign a variable by reference in Lua to another one?
For example: want to do equivalent of \"a = b\" where a will then be a pointer to b
Backgr
It's true the variables are just names for values. But you can compute variable names, if you are dealing with keys in a table. This means you can use key names to perform your conditional logic.
myvars = { a=1, b=2, c=3.14 }
function choose(input)
print(myvars[input])
end
choose('a')
choose('b')
a = 'a'
choose(a)
b = a
choose(b)
a = 'c'
choose(a)
choose(b)
Output:
1
2
1
1
3.14
1