#### 3.1.13 Script Variables

A very powerful new feature in Ogre 1.6 is variables. Variables allow you to parameterize data in materials so that they can become more generalized. This enables greater reuse of scripts by targeting specific customization points. Using variables along with inheritance allows for huge amounts of overrides and easy object reuse.

    abstract pass ParentPass
    {
       diffuse $diffuse_colour
    }

    material Test
    {
       technique
       {
           pass : ParentPass
           {
               set $diffuse_colour "1 0 0 1"
           }
       }
    }

The ParentPass object declares a variable called "diffuse_colour" which is then overridden in the Test material’s pass. The "set" keyword is used to set the value of that variable. The variable assignment follows lexical scoping rules, which means that the value of "1 0 0 1" is only valid inside that pass definition. Variable assignment in outer scopes carry over into inner scopes.

    material Test
    {
        set $diffuse_colour "1 0 0 1"
        technique
        {
            pass : ParentPass
            {
            }
        }
    }

The $diffuse_colour assignment carries down through the technique and into the pass.