So I have an interesting problem to solve.
I would like to modify a local variable inside a function
This is what I would like to do:
Code: Select all
local a = 10
print(a) -->>output 10
myFunction = function(_value)
_value = _value + 1
end
myfunction(a)
print(a) -->> output 11
I was searching the Lua documentations and the web but could not find any solution.
One thing that was repeatedly come up in searches is to use a C module to use pointers to get a reference to the variable in memory but no info was shared how to do that exactly and I don't have a lot of experience with C.
So I was wondering, is there anything like a pointer in Lua to pass a variable by reference to a function or could someone recommend a library to work with memory addresses of variables to get around this?
I would appreciate any help.
Thank you.