Change camera distance with mouse wheel

edited March 31 in Tutorials

Hi.
For my mod, I wanted to change camera distance with the mouse wheel, but it was difficult to find how can I do it.
So I decided to write a small guide, maybe I help someone else.

At first add javascipt file and write code:

var cameradist = 1300;   //start camera distance in dota
var speed = 15;
var minCameraDist = 400;
var maxCameraDist = 2200;
GameUI.SetCameraDistance(cameradist);

//mouse wheel call event "wheeled", and arg means wheel direction
GameUI.SetMouseCallback( function( eventName, arg ) {     
    if ( eventName === "wheeled" )
    {
        if ( arg < 0 && cameradist >= minCameraDist)
        {
            cameradist -= speed;
            GameUI.SetCameraDistance(cameradist);
        }
        else if ( arg > 0 && cameradist <= maxCameraDist)
        {
            cameradist += speed;
            GameUI.SetCameraDistance(cameradist);
        }
    }
    return false;
} );

okey try test and you'll see
alt text
Go fix it.
shift+e and add entity env_fog_controller
alt text
Set Far Z CLip Plane rendering distance, I use 5000. Profit:
alt text