are there ways of doing pointers in lua?
I was trying to make an object that stored certain things in an internal table, but allowed some of it to be referenced outside of the table
eg:
User = {}
User.data = {}
User.Username = (point to User.data.username)
User.Password = (point to User.data.ScramblePassword())
I tried making the data table have functions that returned the data and setting the values I wanted to refer to that data to the results of those functions like so:
Triangle = {}
Triangle.vector1 = {}
Triangle.vector1.x = 0
Triangle.vector1.refx = function() return Triangle.vector1.x = 0 end
Triangle.X = Triangle.vector1.ref()
But this didn't work because Triangle.X is then technically a value type, not a reference type.
I don't want to use functions as a reference type like so:
Triangle = {}
Triangle.vector1 = {}
Triangle.vector1.x = 0
Triangle.X = function() return Triangle.vector1.x = 0 end
Because that would mean having to call Triangle.X() and the brackets are unnatural and not very user friendly.
Ultimately I want to achieve this:
Triangle.X = (points to)Triangle.vector1.x
--so that--
Triangle.X = 5
print(Triangle.X) --prints 5
print(Triangle.vector1.x) --prints 5
Triangle.vector.x = 10
print(Triangle.X) --prints 10
print(Triangle.vector1.x) --prints 10
so really what I want to know is:
A) Does lua have pointers in a way that I can make an object member point to a place storing a value type without having to call that member as a function (ie with brackets)?
B)If not, is there a way this can be replicated with metatables, for example storing the value as a table and have it's reference refer to an internal value as opposed to that table's place in memory?