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?
Can i send reference to a variable to a function?
Re: Can i send reference to a variable to a function?
Just pointing out that i do have a way around this problem, mainly sending both table and variable as separate info to the function and that way being able to do what i intend to, but it would be simpler if i would only need to send the reference to that variable inside a table.
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Can i send reference to a variable to a function?
No, that's not possible. Just pass the table and modify the table member inside the function. Then it will automatically change in all table instances.