mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-06 07:20:30 +00:00
Add __eq metamethod and equals method to the vector api. (#800)
This commit is contained in:
parent
38335ca187
commit
7fc55aa9a0
@ -151,6 +151,15 @@ local vector = {
|
||||
tostring = function(self)
|
||||
return self.x .. "," .. self.y .. "," .. self.z
|
||||
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 = {
|
||||
@ -161,6 +170,7 @@ local vmetatable = {
|
||||
__div = vector.div,
|
||||
__unm = vector.unm,
|
||||
__tostring = vector.tostring,
|
||||
__eq = vector.equals,
|
||||
}
|
||||
|
||||
--- Construct a new @{Vector} with the given coordinates.
|
||||
|
Loading…
Reference in New Issue
Block a user