✓ Accepted answer
In Lua, Objects are simply metadata, advanced forms of arrays built with metamethods (functions) to modify itself. Vector3 is one of these Instances.
For an easier understanding, let’s take a look at what the Vector3 constructor looks like:
local Vector3 = {}
Vector3.__index = Vector3
Vector3.new = (function(x,y,z)
local self = setmetatable({},Vector3)
self.X = tonumber(x) or 0
self.Y = tonumber(y) or 0
self.Z = tonumber(z) or 0
return self
end)
return Vector3
This is a highly complicated branch of tables known as Object Orientated Programming, so I won’t necessarily go into explaining how all of the code above works. But do notice one thing, Vector3 is assigned as an array. If we don’t call the .new() constructor to build our Vector data, we simply just end up passing a table.
3 comments
Vector3 is assigned as a dictionary not an array
“Advanced form of an array”.
ok so I think im understanding it so i need to use .new() in order to make a new Vector3 and by itself it is a array or something like that.