LSL Wiki Mirror 10-5-2006: llGetRegionTimeDilation

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings ::
float llGetRegionTimeDilation()

Returns the time dilation of the current region (simulator) as a float between 0 and 1.

Time dilation occurs when the sim can't keep up with the processing of its tasks even after reducing the time allocated to scripts and physics. Avatars will experience this as slowed-down (slow-motion, "bullet-time") movement.

If you have many scripts running in a sim (or physical objects), it would be considerate to pause them when the time dilation drops below a certain threshold (0.8 - 0.9).

See llGetRegionFPS and lag.

This is a script that will automatically pause all scripts once dilation drops below 0.65:

// string giv(integer type,integer i) {
    return llGetInventoryName(type,i);
}

default
{
    on_rez(integer s) { llResetScript();} // Habit - llGetOwner() has a habit of returning the old owner's name when given to another person.

    state_entry()
    {
        llSetTimerEvent(0.3); //Repeat every 3/10th of a second.
    }

    timer() {
        float dilation = llGetRegionTimeDilation(); //Get the dilation
        if(dilation < 0.65) {  //If the dilation is less than 65%
            llOwnerSay("Time Dilaton is critical! Pausing scripts!"); //Say to the owner that message
            integer x;
            for(x=0;x<llGetInventoryNumber(INVENTORY_SCRIPT);x++) {
                if(giv(INVENTORY_SCRIPT,x) != llGetScriptName()) { //If the script number x is not this script
                    llSetScriptState(giv(INVENTORY_SCRIPT,x),FALSE); //Pause it
                }
            }
            llOwnerSay("Done.");
        }
        else { //If the dilation is more than 65%
            integer x;
            for(x=0;x<llGetInventoryNumber(INVENTORY_SCRIPT);x++) {
                if(giv(INVENTORY_SCRIPT,x) != llGetScriptName()) {
                    llSetScriptState(giv(INVENTORY_SCRIPT,x),TRUE); //Enable all scripts
                }
            }
        }
    }
}


Functions | Simulator | Time | Lag
There is no comment on this page. [Display comments/form]