Dimencia

Untitled

Sep 10th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.02 KB | None | 0 0
  1.  
  2. Start()
  3.  
  4. pitchInput = 0
  5. rollInput = 0
  6. yawInput = 0
  7. brakeInput = 0
  8. system.lockView(1)
  9. simulatedX = 0
  10. simulatedY = 0
  11.  
  12.  
  13.  
  14. Update()
  15.  
  16. local MouseYSensitivity = 0.01 --export: Sensitivity for Y-axis mouse movement
  17. local MouseXSensitivity = 0.01 --export: Sensitivity for X-axis mouse movement
  18. local DeadZone = 50 --export: Number of pixels of deadzone near the center of the screen
  19.  
  20. local deltaX = system.getMouseDeltaX()
  21. local deltaY = system.getMouseDeltaY()
  22.  
  23.  
  24. if system.isViewLocked() == 0 then
  25.     system.showScreen(0)
  26.    
  27. else
  28.     simulatedX = simulatedX + deltaX
  29.     simulatedY = simulatedY + deltaY
  30.     system.showScreen(1)
  31.     -- Should draw an outer DeadZone circle as well as the cursor
  32.     local content = "<svg width='100%' height='100%'><circle stroke='white' cx='calc(50% + " .. simulatedX .. "px)' cy='calc(50% + " .. simulatedY .. "px)' r='5'/><circle cx='50%' cy='50%' r='".. DeadZone .. "' stroke='white' stroke-width='2' fill='none' />"
  33.  
  34.  
  35.     if simulatedX > 0 and simulatedX > DeadZone then
  36.         yawInput = -(simulatedX - DeadZone) * MouseXSensitivity
  37.     elseif simulatedX < 0 and simulatedX < (DeadZone * -1) then
  38.         yawInput = -(simulatedX + DeadZone) * MouseXSensitivity
  39.     else
  40.         yawInput = 0
  41.     end
  42.  
  43.     if simulatedY > 0 and simulatedY > DeadZone then
  44.         pitchInput = -(simulatedY - DeadZone) * MouseYSensitivity
  45.     elseif simulatedY < 0 and simulatedY < (DeadZone * -1) then
  46.         pitchInput = -(simulatedY + DeadZone) * MouseYSensitivity
  47.     else
  48.          pitchInput = 0
  49.     end
  50.  
  51.      local distance = math.sqrt(simulatedX*simulatedX + simulatedY*simulatedY)
  52.     if distance > DeadZone then -- Draw a line to the cursor from the screen center
  53.         -- Note that because SVG lines fucking suck, we have to do a translate and they can't use calc in their params
  54.         content = content .. "<line x1='0' y1='0' x2='" .. simulatedX .. "px' y2='" .. simulatedY .. "px' style='stroke:rgb(255,255,255);stroke-width:2;transform:translate(50%, 50%)' />"
  55.     end
  56.  
  57.    
  58.     content = content .. "</svg>"
  59.     system.setScreen(content)
  60.  
  61.  
  62. end
  63.  
  64. Nav:update()
Advertisement
Add Comment
Please, Sign In to add comment