Don't click here unless you want to be banned.

LSL Wiki : llGetRegionTimeDilation

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl814.us.archive.org
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:

integer running;

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.
        running = TRUE;
    }

    timer() {
        float dilation = llGetRegionTimeDilation(); //Get the dilation
        if(dilation < 0.65 && running) {  //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
                }
            }
            running = FALSE;
            llOwnerSay("Done.");
        }
        else
        if (!running)
        { //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
                }
            }
            running = TRUE;
        }
    }
}


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Simulator | Time | Lag
There are 4 comments on this page. [Display comments/form]