Robear9992

coord

Jul 2nd, 2022 (edited)
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. --cc:Tweaked: Coordinates
  2. --pastebin get FDfbWryd coord.lua
  3.  
  4.  
  5. local function coord(x,y,z)
  6.  
  7.   local self = {x=x or 0,y=y or 0,z=z or 0}
  8.  
  9.   function self.union (a) --A = complete, b = partial
  10.     return coord(a.x or self.x,a.y or self.y,a.z or self.z)
  11.   end
  12.  
  13.   function self.copy()
  14.     return coord(self.x,self.y,self.z)
  15.   end
  16.  
  17.   function self.isZero()
  18.     return self.x==0 and self.y==0 and self.z == 0
  19.   end
  20.  
  21.   function self.add(a)
  22.     return coord(self.x + a.x, self.y + a.y, self.z + a.z)
  23.   end
  24.  
  25.   function self.subtract(a)
  26.     return coord(self.x - a.x, self.y - a.y, self.z - a.z)
  27.   end
  28.  
  29.   function self.breakout()
  30.     return self.x, self.y, self.z
  31.   end
  32.  
  33.   function self.equals(a)
  34.     return
  35.       self.x == a.x and
  36.       self.y == a.y and
  37.       self.z == a.z
  38.   end
  39.  
  40.   return self
  41.  
  42. end
  43.  
  44. return coord
  45.  
Add Comment
Please, Sign In to add comment