Advertisement
EchoReaper

Untitled

Aug 12th, 2016
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. function recurse(root,callback)
  2.     for i,v in pairs(root:GetChildren()) do
  3.         callback(i,v)
  4.    
  5.         if #v:GetChildren() > 0 then
  6.             recurse(v,callback)
  7.         end
  8.     end
  9. end
  10. _G.recurse = recurse
  11.  
  12. local aggressiveness = 4
  13. local lowerLimit = {
  14.     [0] = 0.06;
  15.     [1] = 0.1;
  16.     [2] = 0.2;
  17.     [3] = 0.3;
  18.     [4] = 0.4;
  19. }
  20. local upperLimit = {
  21.     [0] = 0.994;
  22.     [1] = 0.9;
  23.     [2] = 0.8;
  24.     [3] = 0.7;
  25.     [4] = 0.6;
  26. }
  27.  
  28. function round(n, aggressiveness)
  29.     local sign = n < 0 and -1 or 1
  30.     n = math.abs(n)
  31.    
  32.     if n - math.floor(n) <= lowerLimit[aggressiveness] then
  33.         --print("small",angle)
  34.         return math.floor(n) * sign
  35.     elseif n - math.floor(n) >= upperLimit[aggressiveness] then
  36.         --print("small missing",angle)
  37.         return (math.floor(n)+1) * sign
  38.     end
  39.    
  40.     return n * sign
  41. end
  42.  
  43.  
  44. function _G.fixRotation(part)
  45.     local originalCFrame = part.CFrame
  46.     local rotation = part.Rotation
  47.     local size = part.Size
  48.     local newRotation = Vector3.new(round(rotation.X, aggressiveness), round(rotation.Y, aggressiveness), round(rotation.Z, aggressiveness))
  49.    
  50.     --print("Rotations", rotation,"::",newRotation)
  51.     part.Rotation = newRotation
  52.     if not part:IsA("PartOperation") then
  53.         part.Size = Vector3.new(round(size.X, 0), round(size.Y, 0), round(size.Z,0))
  54.     end
  55.     part.CFrame = part.CFrame - part.CFrame.p + originalCFrame.p
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement