Changing mouse button for Binoculars

Post » Tue Nov 30, 2010 9:45 am

With http://www.tesnexus.com/downloads/file.php?id=6964 you can zoom in on stuff by holding down the right mouse button to activate them and using the mouse wheel to zoom in and out. I like it a lot but would like to change the activate button as I'd like to keep the right mouse button for block. I get a bit confused by the script, though, so I'm not sure what to change. Also, how do I know which is, say, Mouse Button 3 on my http://www.logitech.com/en-gb/mice_pointers/mice/devices/4259? Here's the script in question:

ScriptName BinocZoomscript;Variablesshort iMouseWheelUpshort iMouseWheelDownshort iMouseBut1short iMouseBut2short iMouseBut3short iMouseBut4short iMouseBut5short iNormalshort bBinequippedshort iZoomvalueshort bInitializefloat fVanityModeWheelMultBackupfloat zoomFac;UserRef is the actor that has the Binocularsref UserRefBegin OnAdd	; Get whomever is holding this object	set UserRef to GetContainerEnd;----------UnEquipping the binoculars--------------Begin OnUnequipset bBinequipped 	to 0;Enable mouse wheel and buttonsEnableKey iMouseBut2EnableKey iMouseBut3	EnableKey iMouseWheelUpEnableKey iMouseWheelDown;Return zoom alue to normal;set iZoomvalue 		to 75con_SetCameraFOV 90End;----------Equipping the binoculars--------------Begin OnEquipset Bbinequipped 	to 1;Disable mouse wheel and buttonsDisableKey iMouseBut2Set fVanityModeWheelMultBackup to GetGameSetting fVanityModeWheelMult	;con_SetCameraFOV iZoomvalueEndBegin GameMode;----------Mouse wheel--------------;Initialize variablesif bInitialize !=1Set iMouseWheelUp	to 264Set iMouseWheelDown	to 265Set iMouseBut1		to 256Set iMouseBut2		to 257Set iMouseBut3		to 258Set iMouseBut4		to 259Set iMouseBut5		to 260set bBinequipped 	to 0set iZoomvalue 		to 90Set bInitialize		to 1endifIf bBinequipped == 1			If IsKeyPressed2 iMouseBut2 == 1				con_SetCameraFOV iZoomvalue		DisableKey iMouseBut3		DisableKey iMouseWheelUp		DisableKey iMouseWheelDown				;Disable vanity cam		SetNumericGameSetting fVanityModeWheelMult 0.0			; ***** Mouse Wheel zooms *****		If IsKeyPressed2 iMouseWheelDown == 1			if iZoomvalue < 90			PlaySound BinocZoomOut			Set iZoomvalue to iZoomvalue + 5			Endif		ElseIf IsKeyPressed2 iMouseWheelUp == 1			if iZoomvalue > 5			PlaySound BinocZoomIn			Set iZoomvalue to iZoomvalue - 5			Endif		ElseIf IsKeyPressed2 iMouseBut3 == 1			Set zoomFac to 90/iZoomvalue			Message " %.2f  X", zoomFac,1 		EndIf		con_SetCameraFOV iZoomvalue			else		EnableKey iMouseBut3			EnableKey iMouseWheelUp		EnableKey iMouseWheelDown				;Enable vanity camera		SetNumericGameSetting fVanityModeWheelMult fVanityModeWheelMultBackup		con_SetCameraFOV 90			endifendifend


Any help appreciated.
User avatar
Tina Tupou
 
Posts: 3487
Joined: Fri Mar 09, 2007 4:37 pm

Post » Mon Nov 29, 2010 11:36 pm

You need to change this:

if bInitialize !=1Set iMouseWheelUp	to 264Set iMouseWheelDown	to 265Set iMouseBut1		to 256Set iMouseBut2		to 257Set iMouseBut3		to 258Set iMouseBut4		to 259Set iMouseBut5		to 260set bBinequipped 	to 0set iZoomvalue 		to 90Set bInitialize		to 1endif


The buttons are specified by direct x scancodes, a list can be found http://cs.elderscrolls.com/constwiki/index.php/IsKeyPressed2. Just change the buttons you want to a different scancode. You also need to change bInitialize to 2 or the initialization block won't run again if the mod was already active in a savegame you load. Like

if bInitialize != 2Set iMouseWheelUp	to 264Set iMouseWheelDown	to 265Set iMouseBut1		to 256Set iMouseBut2		to 29Set iMouseBut3		to 258Set iMouseBut4		to 259Set iMouseBut5		to 260set bBinequipped 	to 0set iZoomvalue 		to 90Set bInitialize		to 2endif


for example should update the buttons and set the controls that were assigned to the right mouse button to left control.

EDIT: Not sure how to find out the mouse button number on your mouse (except for the obvious ones like left and right). If no one knows you could just try with a debug message to find out.
User avatar
Josephine Gowing
 
Posts: 3545
Joined: Fri Jun 30, 2006 12:41 pm

Post » Tue Nov 30, 2010 5:48 am

snip


Excellent. I basically tested different scancodes and got the one I wanted on the second try. Perfect. Thanks! :)
User avatar
jasminĪµ
 
Posts: 3511
Joined: Mon Jan 29, 2007 4:12 am


Return to IV - Oblivion