Difference between revisions of "LlGetDayOffset"
Jump to navigation
Jump to search
Tapple Gao (talk | contribs) m (slightly better comments in the example script) |
(Formatting update, add new related function.) |
||
Line 3: | Line 3: | ||
|func_desc=Return the number of seconds added to the current time before calculating the current environmental time for the parcel. [[llGetDayOffset ]] returns the value for the current parcel, [[llGetRegionDayOffset]] produces the same value for the entire region. | |func_desc=Return the number of seconds added to the current time before calculating the current environmental time for the parcel. [[llGetDayOffset ]] returns the value for the current parcel, [[llGetRegionDayOffset]] produces the same value for the entire region. | ||
|examples= | |examples= | ||
< | <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: | ||
} | } | ||
} | } | ||
</ | </syntaxhighlight> | ||
|also_functions= | |also_functions= | ||
{{LSL DefineRow||[[llGetEnvironment]]}} Newer function that consolidates many environment-based settings. | |||
{{LSL DefineRow||[[llGetDayLength]]}} | |||
{{LSL DefineRow||[[llGetDayOffset]]}} | |||
{{LSL DefineRow||[[llGetMoonDirection]]}} | |||
{{LSL DefineRow||[[llGetMoonRotation]]}} | |||
{{LSL DefineRow||[[llGetSunDirection]]}} | |||
{{LSL DefineRow||[[llGetSunRotation]]}} | |||
{{LSL DefineRow||[[llGetRegionDayLength]]}} | |||
{{LSL DefineRow||[[llGetRegionDayOffset]]}} | |||
{{LSL DefineRow||[[llGetRegionMoonDirection]]}} | |||
{{LSL DefineRow||[[llGetRegionMoonRotation]]}} | |||
{{LSL DefineRow||[[llGetRegionSunDirection]]}} | |||
{{LSL DefineRow||[[llGetRegionSunRotation]]}} | |||
}} | }} |
Latest revision as of 08:44, 23 August 2022
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: integer llGetDayOffset( );
Return the number of seconds added to the current time before calculating the current environmental time for the parcel. llGetDayOffset returns the value for the current parcel, llGetRegionDayOffset produces the same value for the entire region.
Returns an integer
Caveats
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() + llGetDayOffset()) % llGetDayLength() * 1.0 / llGetDayLength();
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 |