Advertisement
TheDev321

Untitled

Jul 28th, 2021
1,018
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. module.BuildMode = function(self, plot)
  2.     if isInterpolating then
  3.         return
  4.     end
  5.     if plot and not inBuild then
  6.         inBuild = true
  7.         module:TweenFromChar(module:GetBuildPos(plot, true), 1)
  8.         zoom = 1
  9.         rotation = 0
  10.         --camPos = Vector3.new(0, 0, -50)
  11.         local movementDelta = Vector2.new(0, 0)
  12.         do
  13.             local keysDown = {}
  14.             local oldPos, conDown, conUp, conChange = nil, nil, nil, nil
  15.             local mousePos = Vector2.new(mouseZoneOffset + 1, mouseZoneOffset + 1)
  16.             local rotateFlat = 0
  17.             local zoomFlat = 0
  18.             local lastThumbstick = Vector2.new()
  19.             local setZoom = function(value)
  20.    
  21.             zoom = clamp(value, 0, 3)
  22.         end
  23.  
  24.         conChange = inputService.InputChanged:connect(function(obj, used)
  25.    
  26.         if obj.UserInputType.Name == "MouseWheel" and not used then
  27.             setZoom(zoom - obj.Position.z * zoomSpeed)
  28.         else
  29.             if obj.UserInputType.Name == "MouseMovement" then
  30.                 mousePos = obj.Position
  31.                 if keysDown.RButton then
  32.                     do
  33.                     if oldPos then
  34.                         local delta = oldPos.X - mousePos.X
  35.                         rotation = rotation + delta * rotSpeed
  36.                     end
  37.                     oldPos = mousePos
  38.                     if obj.UserInputType.Name:sub(1, 7) == "Gamepad" and obj.KeyCode.Name == "Thumbstick2" then
  39.                         local x, y = obj.Position.X, obj.Position.Y
  40.                         if (thumbstickDeadzone >= math.abs(x) or not -x) and (thumbstickDeadzone >= math.abs(lastThumbstick.X) or not 0) then
  41.                             rotateFlat = not keysDown.ButtonL1 or rotateFlat
  42.                             zoomFlat = (thumbstickDeadzone < math.abs(y) and y) or (thumbstickDeadzone < math.abs(lastThumbstick.Y) and 0) or zoomFlat
  43.  
  44.                             if (((thumbstickDeadzone >= math.abs(x) or not -x) and thumbstickDeadzone < math.abs(lastThumbstick.X) and thumbstickDeadzone >= math.abs(y)) or not y) and (thumbstickDeadzone >= math.abs(lastThumbstick.Y) or not 0) then
  45.                                 movementDelta = Vector2.new(movementDelta.X, movementDelta.Y)
  46.                                 lastThumbstick = obj.Position
  47.                             end
  48.                         end
  49.                     end
  50.                 end
  51.             end
  52.         end
  53.     end
  54. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement