mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Add __eq metamethod and equals method to the vector api. (#800)
This commit is contained in:
		| @@ -151,6 +151,15 @@ local vector = { | |||||||
|     tostring = function(self) |     tostring = function(self) | ||||||
|         return self.x .. "," .. self.y .. "," .. self.z |         return self.x .. "," .. self.y .. "," .. self.z | ||||||
|     end, |     end, | ||||||
|  |  | ||||||
|  |     --- Check for equality between two vectors. | ||||||
|  |     -- | ||||||
|  |     -- @tparam Vector self The first vector to compare. | ||||||
|  |     -- @tparam Vector other The second vector to compare to. | ||||||
|  |     -- @treturn boolean Whether or not the vectors are equal. | ||||||
|  |     equals = function(self, other) | ||||||
|  |         return self.x == other.x and self.y == other.y and self.z == other.z | ||||||
|  |     end, | ||||||
| } | } | ||||||
|  |  | ||||||
| local vmetatable = { | local vmetatable = { | ||||||
| @@ -161,6 +170,7 @@ local vmetatable = { | |||||||
|     __div = vector.div, |     __div = vector.div, | ||||||
|     __unm = vector.unm, |     __unm = vector.unm, | ||||||
|     __tostring = vector.tostring, |     __tostring = vector.tostring, | ||||||
|  |     __eq = vector.equals, | ||||||
| } | } | ||||||
|  |  | ||||||
| --- Construct a new @{Vector} with the given coordinates. | --- Construct a new @{Vector} with the given coordinates. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Matthew Wilbern
					Matthew Wilbern