Timed Lights - Need to know...
|
Daitenshi Kato
Registered User
Join date: 30 May 2003
Posts: 12
|
06-22-2003 20:12
I need to figure out how much time is between sunrise and sunset. If you have any idea, please reply. I really need a specific response, as specific as possible so its realistic. I've heard roughly 3-4 hours, but I can't work with that  Thanks.
|
Alek Wu
LEFT-HANDED ELF!
Join date: 16 Apr 2003
Posts: 237
|
06-22-2003 22:52
Talk to Ama Omega... he rigged our clock tower to tell our windows in the village when night is so they glow bright yellow. (:
|
Philip Linden
Founder, Linden Lab
Join date: 18 Nov 2002
Posts: 428
|
06-22-2003 23:31
There is a scripting command that tells the location of the sun in the sky - this is the one to use for timed street lights.
|
Daitenshi Kato
Registered User
Join date: 30 May 2003
Posts: 12
|
06-23-2003 05:58
Hey, I found out the llGetSunDirection; code but im not quite sure how to use it. All i have is llGetSunDirection(); I tried to make the object say where the sun was, but being a newb to scripting has been troublesome. Any help is appreciated, and yes I contacted Ama 
|
Xylor Baysklef
Scripting Addict
Join date: 4 May 2003
Posts: 109
|
06-23-2003 17:15
I think llGetTimeOfDay(), which (I'm pretty sure) returns the "in world" time, might work. (As opposed to llGetWallclock(), which returns server time).
Xylor
|
Ama Omega
Lost Wanderer
Join date: 11 Dec 2002
Posts: 1,770
|
06-23-2003 22:40
vector sun = llGetSunDirection(); integer isDay = ( sun.z > 0 ); isDay will be TRUE if it is day, FALSE if it is night.
|
Daitenshi Kato
Registered User
Join date: 30 May 2003
Posts: 12
|
06-24-2003 19:55
Well i compiled a script to make it work properly...well in theory it SHOULD have worked, but what it does is just flash the colour i need it to change to then goes back to the original, but if you check in textures, under colour, it worked. Here's an example of what i have:
default { state_entry() { vector sun = llGetSunDirection(); integer isDay = ( sun.z > 0 ); if ( isDay = FALSE ); { llSetColor(<1.0, 0.0, 0.0>, ALL_SIDES); } if ( isDay = TRUE ); { llSetColor(<0.2, 0.0, 0.0>, ALL_SIDES); }
} touch_start(integer total_number) { llSay(0,""+(string)llGetSunDirection()); } }
Let me know whats wrong with it.
|
si Money
The nice demon.
Join date: 21 May 2003
Posts: 477
|
06-24-2003 21:25
From: someone Originally posted by Daitenshi Kato Well i compiled a script to make it work properly...well in theory it SHOULD have worked, but what it does is just flash the colour i need it to change to then goes back to the original, but if you check in textures, under colour, it worked. Here's an example of what i have:
default { state_entry() { vector sun = llGetSunDirection(); integer isDay = ( sun.z > 0 ); if ( isDay = FALSE ); { llSetColor(<1.0, 0.0, 0.0>, ALL_SIDES); } if ( isDay = TRUE ); { llSetColor(<0.2, 0.0, 0.0>, ALL_SIDES); }
} touch_start(integer total_number) { llSay(0,""+(string)llGetSunDirection()); } }
Let me know whats wrong with it. Change your isDay = FALSE and isDay = TRUE to isDay == FALSE and isDay == TRUE, otherwise you are assigning the value in your if statement, which is definitely not what you want, = is assignment == is comparison.
|
Sphereon Nomad
Registered User
Join date: 8 Jun 2003
Posts: 22
|
06-25-2003 09:17
Something else you could do, because isDay is returning a boolean value (i.e. true or false) and would make it simpler:
if (isDay) //This will happen if isDay is TRUE { llSetColor(<0.2, 0.0, 0.0>, ALL_SIDES); } else //Otherwise, this will happen { llSetColor(<1.0, 0.0, 0.0>, ALL_SIDES); }
Also, don't put semicolons after your "if" or "else" statements. or anything that is followed by an opening brace {
- Sphereon Nomad "a sphere is worth a thousand polygons"
|
Daitenshi Kato
Registered User
Join date: 30 May 2003
Posts: 12
|
06-25-2003 09:50
Well i'm really close now. I did what you said about the ==. but now they dont turn off or on based on the sun. See I added a say line so i know if it works or not, and when i reversed the true and false to make it think it was night, it ran through both llSay and said both of them. The lights do work if i reset the script though. Here's a copy of what i have: default { state_entry() { vector sun = llGetSunDirection(); integer isDay = ( sun.z > 0 ); if ( isDay == FALSE ); { llSetColor(<1.0, 0.0, 0.0>, ALL_SIDES); llSay(0, "Lights Activated"  ; } if ( isDay == TRUE) { llSetColor(<0.2, 0.0, 0.0>, ALL_SIDES); llSay(0, "Lights Deactivated"  ; } } touch_start(integer total_number) { llSay(0,""+(string)llGetSunDirection()); } } So like i said, when i activate the script, it says "Lights Activated" then immidiatly after "Lights Deactivated" but they stay on.. or off dependant on the day. And i tried working with the else statement, I probably didn't do it right cuz it doesnt work either
|
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
|
06-25-2003 11:14
Your code that checks the value of isDay is in the state_entry handler for the default state; that means it's being executed only once, when the script starts running. (Resetting the script starts it over again.) You want to check the value of isDay at regular intervals, say every five or ten minutes. For that you need the timer event. Try this: default { state_entry() { // set interval at 300 seconds, i.e. five minutes llSetTimerEvent( 300.0 ); }
timer() { vector sun = llGetSunDirection(); integer isDay = ( sun.z > 0 ); if ( isDay == FALSE ); { llSetColor(<1.0, 0.0, 0.0>, ALL_SIDES); llSay(0, "Lights Activated"); } if ( isDay == TRUE) { llSetColor(<0.2, 0.0, 0.0>, ALL_SIDES); llSay(0, "Lights Deactivated"); }
}
touch_start(integer total_number) { llSay(0,""+(string)llGetSunDirection()); }
}
|
Jericho Powers
Hero Without A Cause
Join date: 31 Dec 1969
Posts: 166
|
06-25-2003 11:31
Another thing you could try is have an object using light material rez inside you light which wouldn't be a light material object and have it die when not needed. This might cut down on lighting taxes as well.
_____________________
Gibson, thereabouts.
|
Daitenshi Kato
Registered User
Join date: 30 May 2003
Posts: 12
|
06-25-2003 13:10
Thats a good idea, but i dont need it lol, its only 10 bucks to have them both out 
|
Daitenshi Kato
Registered User
Join date: 30 May 2003
Posts: 12
|
06-25-2003 18:46
This is a follow up - The lights do currently work  I'd like to say thank you to everyone who contributed to the script. So umm yeah if u need the script IM me in game and ill give u a copy. Thanks again!
|