Jump to content
Sign in to follow this  
Sky Linnaeus

Script to change texture at a specific time?

You are about to reply to a thread that has been inactive for 2925 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I need to create an object that will change textures once per day at 9 pm slt. The script I have right now is

 

list textures = ["0ec3304e-6eda-9556-7306-acb0846685de",
"17ce195b-4077-910b-1464-7dd086f8d63a",
"f0015cd5-47f4-d192-dead-024148b2bd14",
"21ffc27d-dc56-c10b-0194-4def0635ae0a",
"20cae3ac-4111-9d63-48d6-c890d10f2351"];
float INTERVAL=30.0;
integer HOUR_OFFSET=-4;

update()
{
integer time=llGetUnixTime()+(HOUR_OFFSET*3600);

integer day=(time/(24*60*60)) % 5;
integer hour=(time/(60*60)) % 24;
}

integer textures_number;
integer current_index;

default
{state_entry()
{
llSetTimerEvent(INTERVAL);
update();
textures_number = llGetListLength(textures);
}
timer()

{
llSetTexture(llList2String(textures,current_index),0);
if(++current_index >= textures_number)
current_index = 0;
}

}

 

But instead of changing once per day it is changing the script every 30 seconds. This is my first attempt at scripting and I'm really just trying to merge 2 scripts but not succeeding and I've probably mangaled it pretty badly. Can anyone help?

Share this post


Link to post
Share on other sites

This is how I would do the timer, I think.   I've not tested it, but I think this how I've done it in the past.

float NinePM = 75600.0;//21 hours in secondsfloat TwentyFourHours = 86400.0;//24 hours in secondsfloat t;calculate_time(){	float now = llGetWallclock();//get the time now	if(now<NinePM){//if it's before 9pm slt		t = NinePM-now; //seconds till 9pm	}	else{		t = (TwentyFourHours - now)+NinePM;//seconds till midnight, plus 21 hours	}	llSetTimerEvent(t);}default{	state_entry()	{		calculate_time();	}	on_rez(integer start_param)	{		llResetScript();	}	changed(integer change)	{		if(change & CHANGED_REGION_START){			//not sure this is necessary, but it can't hurt			calculate_time();		}	}	timer()//should be 9 pm	{		//do texture stuff		calculate_time();//reset the timer	}}

 Then, in the timer event, you just advance your index by one each time, and reset it to 0 if it's reached the end, and set the appropriate texture.

I wondered about region idling, but I have something I made some time ago that fires once a week, at midnight on Sunday Morning, and it doesn't seem to have affected it.    It did start doing some strange stuff for for two weeks a couple of weeks ago, but whatever was causing that I don't think it was region idling because it was firing too early.   But it's back to normal now.

Share this post


Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 2925 days.

Please take a moment to consider if this thread is worth bumping.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...