Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Start()
- pitchInput = 0
- rollInput = 0
- yawInput = 0
- brakeInput = 0
- system.lockView(1)
- simulatedX = 0
- simulatedY = 0
- Update()
- local MouseYSensitivity = 0.01 --export: Sensitivity for Y-axis mouse movement
- local MouseXSensitivity = 0.01 --export: Sensitivity for X-axis mouse movement
- local DeadZone = 50 --export: Number of pixels of deadzone near the center of the screen
- local deltaX = system.getMouseDeltaX()
- local deltaY = system.getMouseDeltaY()
- if system.isViewLocked() == 0 then
- system.showScreen(0)
- else
- simulatedX = simulatedX + deltaX
- simulatedY = simulatedY + deltaY
- system.showScreen(1)
- -- Should draw an outer DeadZone circle as well as the cursor
- 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' />"
- if simulatedX > 0 and simulatedX > DeadZone then
- yawInput = -(simulatedX - DeadZone) * MouseXSensitivity
- elseif simulatedX < 0 and simulatedX < (DeadZone * -1) then
- yawInput = -(simulatedX + DeadZone) * MouseXSensitivity
- else
- yawInput = 0
- end
- if simulatedY > 0 and simulatedY > DeadZone then
- pitchInput = -(simulatedY - DeadZone) * MouseYSensitivity
- elseif simulatedY < 0 and simulatedY < (DeadZone * -1) then
- pitchInput = -(simulatedY + DeadZone) * MouseYSensitivity
- else
- pitchInput = 0
- end
- local distance = math.sqrt(simulatedX*simulatedX + simulatedY*simulatedY)
- if distance > DeadZone then -- Draw a line to the cursor from the screen center
- -- Note that because SVG lines fucking suck, we have to do a translate and they can't use calc in their params
- 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%)' />"
- end
- content = content .. "</svg>"
- system.setScreen(content)
- end
- Nav:update()
Advertisement
Add Comment
Please, Sign In to add comment