+ Reply to Thread
Results 1 to 4 of 4

Thread: Script not working. Anyone knows why?

  1. #1
    *kadle
    Guest

    Script not working. Anyone knows why?

    I wanted to post a script for the person that asked for a script that makes the scroll wheel zoom when you have the zoom key pressed, and otherwise works as normal when the zoom key isn't pressed.

    Here is the script:

    Code:
    // Zoom levels
    set fov1 "cg_zoomfov 80;cg_zoomsensitivity 1; print Zoom 80"
    set fov2 "cg_zoomfov 55;cg_zoomsensitivity 1; print Zoom 55"
    set fov3 "cg_zoomfov 35;cg_zoomsensitivity 1; print Zoom 35"
    set fov4 "cg_zoomfov 20;cg_zoomsensitivity 1; print Zoom 20"
    
    // Zoom cycle
    set sfov1 "vstr fov1; set lzoom vstr sfov1; set mzoom vstr sfov2"
    set sfov2 "vstr fov2; set lzoom vstr sfov1; set mzoom vstr sfov3"
    set sfov3 "vstr fov3; set lzoom vstr sfov2; set mzoom vstr sfov4"
    set sfov4 "vstr fov4; set lzoom vstr sfov3; set mzoom vstr sfov4"
    
    // Zoom with mousewheel
    set wheel_zoom "bind mwheelup vstr mzoom; bind mwheeldown vstr lzoom"
    
    // Weapon selection with mousewheel
    set wheel_norm "bind mwheelup weapnext; bind mwheeldown weapprev"
    
    // Set gradual zoom to mouse wheel and default zoom to mouse3
    set zwheel "vstr wheel_zoom; bind mouse3 vstr sfov2; +zoom"
    
    // Reset the mouse wheel and mouse3 to their default settings
    set nwheel "vstr wheel_norm; bind mouse3 +button2; -zoom"
    
    // Define the command that toggles the wheel between zoom
    // and weapons toggle.
    set "+myz" "vstr zwheel"
    set "-myz" "vstr nwheel"
    
    // Set defualt cg_zoomfov
    vstr sfov2
    
    // Bind the zoom command
    bind space "+myz"
    
    // Show the user that the script is executed
    echo "Executed zoom.cfg."
    If I execute the script, -myz becomes "32", when you press space the first time, space becomes bound to "32". I tried changing it to backspace, and then -myz became "127" (notice the ascii values of 32 and 127 are space and backspace).

    Does anyone know why?

    I also tried copy pasting the commands, and they work fine, except when you use them, either by pressing space or entering the commands manually, then what I described above happens.

    Is there a limit of the no. of 'vstr' embedded in 'vstr'? And if there is, what is the maximum line length of lines in the config file?

    Best Regards
    Kadle

    See also:
    http://www.quakelive.com/forum/showt...he-mouse-wheel
    Last edited by kadle; 04-10-2012 at 09:47 PM. Reason: spellos and added a link to the original script

  2. #2
    *kadle
    Guest
    Sorry for asking, I should use alias for creating the +myz and -myz.

    Here is the working script with these 2 changes.

    Code:
    // Zoom levels
    set fov1 "cg_zoomfov 80;cg_zoomsensitivity 1; print Zoom 80"
    set fov2 "cg_zoomfov 55;cg_zoomsensitivity 1; print Zoom 55"
    set fov3 "cg_zoomfov 35;cg_zoomsensitivity 1; print Zoom 35"
    set fov4 "cg_zoomfov 20;cg_zoomsensitivity 1; print Zoom 20"
    
    // Zoom cycle
    set sfov1 "vstr fov1; set lzoom vstr sfov1; set mzoom vstr sfov2"
    set sfov2 "vstr fov2; set lzoom vstr sfov1; set mzoom vstr sfov3"
    set sfov3 "vstr fov3; set lzoom vstr sfov2; set mzoom vstr sfov4"
    set sfov4 "vstr fov4; set lzoom vstr sfov3; set mzoom vstr sfov4"
    
    // Zoom with mousewheel
    set wheel_zoom "bind mwheelup vstr mzoom; bind mwheeldown vstr lzoom"
    
    // Weapon selection with mousewheel
    set wheel_norm "bind mwheelup weapnext; bind mwheeldown weapprev"
    
    // Set gradual zoom to mouse wheel and default zoom to mouse3
    set zwheel "vstr wheel_zoom; bind mouse3 vstr sfov2; +zoom"
    
    // Reset the mouse wheel and mouse3 to their default settings
    set nwheel "vstr wheel_norm; bind mouse3 +button2; -zoom"
    
    // Define the command that toggles the wheel between zoom
    // and weapons toggle.
    alias "+myz" "vstr zwheel"
    alias "-myz" "vstr nwheel"
    
    // Set defualt cg_zoomfov
    vstr sfov2
    
    // Bind the zoom command
    bind space "+myz"
    
    // Show the user that the script is executed
    echo "Executed zoom.cfg."
    I wonder how you previously created toggle commands on keydown/up without the alias command.

    Best Regards
    Kadle

  3. #3
    Senior Member Lorfa has a spectacular aura about Lorfa has a spectacular aura about Lorfa's Avatar
    Join Date
    Aug 2010
    Location
    Kepler-22b
    Posts
    5,541
    Quote Originally Posted by kadle View Post
    I wonder how you previously created toggle commands on keydown/up without the alias command.
    There wasn't a direct way. That's why people like me requested +vstr for a very long time before they implemented alias which supports +cvars. It was very frustrating to me because even quake1 had alias with +cvars. Like they can't even use their own code?

    Also there was no cg_zoomScaling cvar for a long time, so in order to get instant zoom that you could hold down on a key you had to use this workaround using +button5:

    bind z "+button5; vstr tog; -button5"
    set tog "vstr togON"
    set togON "cg_fov 52 ; sensitivity 0.3609 ; set tog vstr togOFF"
    set togOFF "cg_fov 107 ; senstivity 1 ; set tog vstr togON"

    Also you had to do the calculation manually for the zoom sens, not a problem just extra work.

    It had a drawback though that if you held it down for more than 5 seconds or so it would start to oscillate between the on and off positions at about 500 ms/cycle. Nowadays all the above can be accomplished with simply:

    cg_zoomfov 52
    bind z +zoom
    cg_zoomscaling 0

    The workaround probably would have worked for making other useful +cvars, but you can see how much simpler it is to just alias +something.

  4. #4
    *kadle
    Guest
    Thanks Lorfa, your the best. As you can see I didn't script quake3+, only simple stuff. I do remember the sensitivty adjustments you had to do when I did the scroll wheel zoom script for quake 2, but I used m_pitch/m_yaw instead of sensitivty - that way it scaled when I changed my sensitivity.

    Best Regards
    Kadle
    Last edited by kadle; 04-11-2012 at 01:02 AM.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts