Difference between revisions of "Script - Zoom"

From FreeSpace Wiki
Jump to: navigation, search
(Created page with '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…')
 
(Minor code cleanup)
Line 21: Line 21:
 
]
 
]
  
 +
$State: GS_STATE_GAME_PLAY
 
$KeyPress: d
 
$KeyPress: d
$State: GS_STATE_GAME_PLAY
+
$On Key Pressed: [
$On Key Pressed:  
 
[
 
 
if runZoomScript then  
 
if runZoomScript then  
 
if not zooming then
 
if not zooming then
Line 46: Line 45:
 
]
 
]
  
$KeyPress: d
+
$On Key Released: [
$State: GS_STATE_GAME_PLAY
 
$On Key Released:
 
[
 
 
if runZoomScript then  
 
if runZoomScript then  
 
if zooming then
 
if zooming then

Revision as of 15:14, 15 July 2010

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