LlGetRegionDayOffset

From Second Life Wiki
Revision as of 21:29, 13 May 2020 by Tapple Gao (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Summary

Function: integer llGetRegionDayOffset( );

Return the number of seconds added to the current time before calculating the current environmental time for the region. llGetDayOffset returns the value for the current parcel, llGetRegionDayOffset produces the same value for the entire region.
Returns an integer

Examples

// print the apparent time of day as HH:MM (%), just like the environment window in the viewer.
// Time of day is a fraction between 0 and 1, 0 is midnight, 0.5 is noon
string printTimeOfDay(float dayFraction) {
    integer hours = (integer)(dayFraction * 24);
    integer minutes = (integer)(dayFraction * 24 * 60) % 60;
    integer percent = (integer)(dayFraction * 100);
    return (string)hours + ":" + llGetSubString((string)(100+minutes), 1, 2) + " (" + (string)percent + "%)";
}
 
default {
    state_entry() {
        llSetTimerEvent(5);
    }
 
    timer() {
        float timeOfDay = (llGetUnixTime() + llGetRegionDayOffset()) % llGetRegionDayLength() * 1.0 / llGetRegionDayLength();
        llSetText(printTimeOfDay(timeOfDay), <1,1,0>, 1);
    }
}

Deep Notes

Search JIRA for related Issues

Signature

function integer llGetRegionDayOffset();