Hi all,
I can't find a simple night and day texture changer. Does anyone have a sample code for this ? Basically only needs to switch between 2 textures for night and day.
Any help greatly appreciated !
Eddepet
These forums are CLOSED. Please visit the new forums HERE
Night/Day Texture switcher wanted. |
|
|
Eddepet Jacobus
Registered User
Join date: 14 Jul 2007
Posts: 2
|
08-24-2007 10:15
Hi all,
I can't find a simple night and day texture changer. Does anyone have a sample code for this ? Basically only needs to switch between 2 textures for night and day. Any help greatly appreciated ! Eddepet |
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
it would work something like this...
08-24-2007 12:27
default {
state_entry() { llSetTimerEvent( 3600 ); } timer() { if( llGetTime() > blah blah blah ) <set the daytume texture> else <set the night time texture> } } Details left as exercise for the student... |
|
Darko Lednev
Registered User
Join date: 20 Aug 2007
Posts: 31
|
08-24-2007 19:13
The script in previous post will work but it will not change the texture when it's nigh or day but when 3600 seconds pass.
Next script will change the textures based on the SLT time. You can click on the object to change the texture or you can set it to auto mode by holding pressed the object for 3 seconds. Place the script along with two textures in your object. *NOTICE* Didn't have time to test it but it should work. ///////////////////////////// Script code \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ string manual_mode = "Manual mode is ON"; string auto_mode = "Automatic mode is ON"; integer light = TRUE; string day = "DayTexture"; // Change the name to your day texture string night = "NightTexture"; // Change the name to your night texture integer hold_stat = FALSE; float elapsed; float deadline = 3; default { state_entry() { llWhisper(0, manual_mode); llSetTexture(day, ALL_SIDES); } touch_start(integer total_number) { hold_stat = TRUE; llResetTime(); } touch(integer total_number ) { if (hold_stat == TRUE) { elapsed = llGetTime(); if (elapsed > deadline) { state auto; hold_stat = FALSE; } } } touch_end( integer total_number ) { hold_stat = FALSE; if (elapsed < deadline ) { if (light == TRUE) { light = FALSE; llSetTexture(day, ALL_SIDES); } else { light = TRUE; llSetTexture(night, ALL_SIDES); } } } } state auto { state_entry() { llWhisper(0, auto_mode); llSetTimerEvent(10); } touch_start(integer total_number) { hold_stat = TRUE; llResetTime(); } touch(integer total_number) { if (hold_stat == TRUE) { elapsed = llGetTime(); if (elapsed > deadline) { state default; hold_stat = FALSE; } } } touch_end( integer total_number) { hold_stat = FALSE; } timer() { vector sun_pos = llGetSunDirection(); if(sun_pos.z > 0) { light = FALSE; llSetTexture(day, ALL_SIDES); } else { light = TRUE; llSetTexture(night, ALL_SIDES); } } } ///////////////////////////// End of code \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ |
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
08-27-2007 00:24
Waaaaay too complicated.
Just check if the suns z coordinate is below 0 using a simple timer. One to two minutes per timer event should more than suffice. llGetSunDirection or similar should yield you the information needed. http://wiki.secondlife.com/wiki/LlGetSunDirection The sun position can be dynamic or static depending upon the wishes of the sim owner. Using this method will make the script automagically adjust itself to the settings in the sim. |
|
Robin Peel
Registered User
Join date: 8 Feb 2005
Posts: 163
|
08-27-2007 07:09
this should work fine, i assume
CODE
|
|
Avion Raymaker
Palacio del Emperador!
Join date: 18 Jun 2007
Posts: 980
|
03-15-2008 00:51
this should work fine, i assume CODE
I'm using Robin's script here, and it works great. But I'm wondering, does setting the event timer at 4 consume unnecessary resources? Would setting it to 60 mean that it would only try out the sun position every minute, instead of every 4 seconds? Thanks --Avion |
|
Anthony Hocken
Registered User
Join date: 16 Apr 2006
Posts: 121
|
03-15-2008 05:28
@Avion. It wouldnt cause alot of lag but checking every 4 seconds seems over the top to me for this. I'd do it every 60 seconds like you say.
_____________________
![]() |
|
Avion Raymaker
Palacio del Emperador!
Join date: 18 Jun 2007
Posts: 980
|
03-15-2008 10:39
Thanks Anthony! I am SUCH a newbie when it comes to scripting, it was an achievement for me just to understand what the number was doing.
And Robin, thanks for the script!The reason I'm concerned about the lag is because I may have up to several hundred of these in the sim. But I don't even know if that makes a difference. I understand that a texture is loaded once and you can repeat it all you want without consuming resources. But I assume an identical script copied many times over would cause a lag penalty? |
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
03-16-2008 11:43
Might be worth testing which seems to cause more time dilation then. Try a thousand timers, then try a thousand listens on some large negative channel. I would expect the listens to be pretty low-lag, since channel is the first thing filtered on (I hope that's not a simple O(N) filter but a search for a list of listeners for each channel, which would be O(log(channels used in sim)), but with SL who knows). Anyway, if the listens turn out to be less costly, then you could have ONE script check the time of day regularly, then message all the others with llRegionSay() at the appropriate time.
|