Difference between revisions of "LlGetRegionDayLength"

From Second Life Wiki
Jump to navigation Jump to search
(add an example script displaying the current region time)
(Formatting update, add new related function.)
 
Line 3: Line 3:
|func_desc=Return the number of seconds in the day cycle applied to the current region. [[llGetDayLength]] returns the number of seconds for the current parcel, [[llGetRegionDayLength]] is the number of seconds in the day cycle applied to the entire region.
|func_desc=Return the number of seconds in the day cycle applied to the current region. [[llGetDayLength]] returns the number of seconds for the current parcel, [[llGetRegionDayLength]] is the number of seconds in the day cycle applied to the entire region.
|examples=
|examples=
<source lang="lsl2">
<syntaxhighlight lang="lsl2">
// print the apparent time of day as HH:MM (%), just like the environment window in the viewer.
// 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
// Time of day is a fraction between 0 and 1, 0 is midnight, 0.5 is noon
Line 23: Line 23:
     }
     }
}
}
</source>
</syntaxhighlight>


|also_functions=
|also_functions=
* [[llGetDayLength]]
{{LSL DefineRow||[[llGetEnvironment]]}} Newer function that consolidates many environment-based settings.
* [[llGetDayOffset]]
{{LSL DefineRow||[[llGetDayLength]]}}
* [[llGetMoonDirection]]
{{LSL DefineRow||[[llGetDayOffset]]}}
* [[llGetMoonRotation]]
{{LSL DefineRow||[[llGetMoonDirection]]}}
* [[llGetSunDirection]]
{{LSL DefineRow||[[llGetMoonRotation]]}}
* [[llGetSunRotation]]
{{LSL DefineRow||[[llGetSunDirection]]}}
* [[llGetRegionDayLength]]
{{LSL DefineRow||[[llGetSunRotation]]}}
* [[llGetRegionDayOffset]]
{{LSL DefineRow||[[llGetRegionDayLength]]}}
* [[llGetRegionMoonDirection]]
{{LSL DefineRow||[[llGetRegionDayOffset]]}}
* [[llGetRegionMoonRotation]]
{{LSL DefineRow||[[llGetRegionMoonDirection]]}}
* [[llGetRegionSunDirection]]
{{LSL DefineRow||[[llGetRegionMoonRotation]]}}
* [[llGetRegionSunRotation]]
{{LSL DefineRow||[[llGetRegionSunDirection]]}}
{{LSL DefineRow||[[llGetRegionSunRotation]]}}
}}
}}

Latest revision as of 08:49, 23 August 2022

Summary

Function: integer llGetRegionDayLength( );

Return the number of seconds in the day cycle applied to the current region. llGetDayLength returns the number of seconds for the current parcel, llGetRegionDayLength is the number of seconds in the day cycle applied to 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);
    }
}

See Also

Functions

•  llGetEnvironment Newer function that consolidates many environment-based settings.
•  llGetDayLength
•  llGetDayOffset
•  llGetMoonDirection
•  llGetMoonRotation
•  llGetSunDirection
•  llGetSunRotation
•  llGetRegionDayLength
•  llGetRegionDayOffset
•  llGetRegionMoonDirection
•  llGetRegionMoonRotation
•  llGetRegionSunDirection
•  llGetRegionSunRotation

Deep Notes

Search JIRA for related Issues

Signature

function integer llGetRegionDayLength();