Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

simulator clock help

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
04-02-2009 11:01
ive been think of this idea for a wile i know sims run on a 4 hour day/night cycle so ive been trying to convert a llGetTimeofDay script to show the sims "time" im incredibly bad at math and not sure how i would convert this script to do that anyone have sugestions?

CODE

default
{
state_entry()
{
llSetTimerEvent(1);
}
timer()
{
float tod = llGetTimeOfDay( );
integer hours = ((integer)tod / 3600) ;
integer minutes = ((integer)tod / 60) - (hours * 60);
llSetText((string) tod + " seconds which is "+(string) hours+"h "+(string) minutes+"m",<1,1,1>,1);
}
}
Ultralite Soleil
Registered User
Join date: 31 Aug 2006
Posts: 108
04-02-2009 11:45
timer()
{
integer seconds = (integer) llGetTimeOfDay( );
seconds = seconds * 6; // SL seconds are 6x faster than RL seconds
integer hours = seconds / 3600;
integer minutes = (seconds % 3600)/60;
string suffix = "am";
if (hours >= 12) suffix = "pm";
llSetText((string)(hours % 12)+":"+(string)minutes+suffix, <1,1,1>, 1);
}

If you want a 24 hour clock, remove the suffix string and the "% 12"
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
04-02-2009 11:57
wow... cant belive it was simple cant belive i even passed math class lolthanks for the help :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-02-2009 19:02
if you want it to also reflect sun-rise/set time in the real world context you'll need a little extra math... in that model sunup is at 3am, and sundown is at 9pm (roughly).

something like..
CODE

integer vBooPM;
seconds = llGetTimeOfDay();
if (600 * 12 > seconds){
seconds = (integer)llSqrt( seconds * 2 ) * 360;
}else{
vBooPM = TRUE;
seconds -= (600 * 12);
seconds = (integer)((seconds / 30)^2 + 2 * seconds);
}


that should scale night faster on the clock than day

EDIT: might help if I calculated seconds instead of hours huh?
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
04-02-2009 20:28
Void, couldn't one use llGetSunDirection(), and use the normalized Z vector to do this?
_____________________
My tutes
http://www.youtube.com/johanlaurasia
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-02-2009 20:30
uh huh, but that was more fun =)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -