Hey, hehe. Probably another dumb question, but I can''t seem to figure this out from the manual. I just wondered, how can you create a reference variable in Lua? I been playing around...
function r(v)
return v
end
a = r
b = r(1)
c = r("Hello")
print(type(a)) -- function
print(type(b)) -- number
print(type(c)) -- string
Right, so a is a reference variable, b and c both hold the return value of r, right? Or is the function body just copied to a? Ok well anyway, that''s simple enough. But how about something like:
function p(x)
x = x + 1
end
d = 1
p(d)
print(d) -- 1
But I want p to change the value of d, not copy it to x. How do I do that?