Script - Zoom

From FreeSpace Wiki
Revision as of 15:14, 15 July 2010 by The E (talk | contribs) (Minor code cleanup)
Jump to: navigation, search

This script enables you to zoom your view so precise aiming is easier.

Table Entry

  • To use create an file called zoom-sct.tbm in your date/tables directory and paste the following code into it:
#Conditional Hooks

$Application: FS2_Open
$On Mission Start: 
[
runZoomScript = true
zoomValue = 0.1
normalFOV = 0.75
zooming = false
defaultZoomSet = false
]

$Application: FS2_Open
$On Mission End: 
[
runZoomScript = false
]

$State: GS_STATE_GAME_PLAY
$KeyPress: d
$On Key Pressed: [
if runZoomScript then 
	if not zooming then
		plr = hv.Player
		if plr:isValid() then
			if #gr.Cameras > 0 then
				cam = gr.Cameras[1]
				if cam:isValid() then
					zooming = true
					if not defaultZoomSet then
						normalFOV = cam.FOV
						defaultZoomSet = true
					end
					zoom = normalFOV * zoomValue
					cam:setFOV(zoom,2,1,0.5)
				end
			end
		end
	end
end
]

$On Key Released: [
if runZoomScript then 
	if zooming then
		plr = hv.Player
		if plr:isValid() then
			if #gr.Cameras > 0 then
				cam = gr.Cameras[1]
				if cam:isValid() then
					zooming = false
					cam:setFOV(normalFOV,2,1,0.5)
				end
			end
		end
	end
end
]

#End