Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Vector3 = {}
- Vector3.functions = {}
- Vector3.functions.__add = function(this, other)
- return Vector3.new(this.X + other.X, this.Y + other.Y, this.Z + other.Z)
- end
- Vector3.functions.__sub = function(this, other)
- return Vector3.new(this.X - other.X, this.Y - other.Y, this.Z - other.Z)
- end
- Vector3.setup = function(new)
- return setmetatable(new, Vector3.functions)
- end
- Vector3.new = function(x, y, z)
- return Vector3.setup({
- X = x, Y = y, Z = z,
- magnitude = math.sqrt(x^2 + y^2 + z^2)
- })
- end
- local x = Vector3.new(10, 15, 20) + Vector3.new(5, 5, 5) - Vector3.new(50, 50, 0)
Advertisement
Add Comment
Please, Sign In to add comment