Can i send reference to a variable to a function?
Posted: Wed Jan 13, 2016 9:16 pm
Here is what i am trying to achieve: (wrong example)
table.variable
function myfunc(func_variable)
func_variable = 1
endfunction
myfunc(table.variable)
What happens now is that when i access myfunc function, it is sending a value. A value that is on "table" at item "variable".
When i in function change that func_variable, it is simply changing the value of a independent copy of that value to 1.
What I would like to happen is, that when i change this value to 1, it would be affecting the value of the "table.variable" to become 1.
Therefore it seems to me like a good solution would be to send a reference of table.variable to that function, in which case it would indeed be changing table.variable to become 1, instead of independent variable,
But is it possible somehow to send a reference to a table item as one of the parameters?
table.variable
function myfunc(func_variable)
func_variable = 1
endfunction
myfunc(table.variable)
What happens now is that when i access myfunc function, it is sending a value. A value that is on "table" at item "variable".
When i in function change that func_variable, it is simply changing the value of a independent copy of that value to 1.
What I would like to happen is, that when i change this value to 1, it would be affecting the value of the "table.variable" to become 1.
Therefore it seems to me like a good solution would be to send a reference of table.variable to that function, in which case it would indeed be changing table.variable to become 1, instead of independent variable,
But is it possible somehow to send a reference to a table item as one of the parameters?