Prim Size Reducer

Written by: Headmaster
// Reducing Script
//
// Kimm Paulino
// Written for Stewart Bosatsu, Sept 2010
 
integer TIMER_STEPS = 18;
float   REDUCING_STEPS = 20;        // If this >= TIMER_STEPS then prim will disappear
float   TIMER_INTERVAL = 2.0;       // In seconds
integer gCount;
vector  gReducingFactor;
 
default
{
    on_rez (integer start_param)
    {
        llResetScript();
    }
 
    state_entry()
    {
        gCount = 0;
        vector size = llGetScale();
        float scaling = 1.0 / REDUCING_STEPS;
        gReducingFactor = size * scaling;
 
    }
 
    touch_start(integer total_number)
    {
        llSetTimerEvent (TIMER_INTERVAL);
    }
 
    timer ()
    {
        // Reduce the size by 1/TIMER_STEPS % each time
        gCount ++;
        if (gCount > TIMER_STEPS)
        {
            // disable and quit
            llSetTimerEvent (0.0);
            llDie();
            return;
        }
 
        // Reduce prim
        vector size = llGetScale();
 
        size = size - gReducingFactor;
        llSetScale (size);
    }
}