Jump to content

Timer Loop to Check for Color Change?


Syle Devin
 Share

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

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

Recommended Posts

I potentially want to hire someone to make and hopefully teach me how a script was made so I can use it fully. Before I can do that I need to find out how much work it would take and if I would be able to afford it.

 

I am trying to make a color change script for furniture. I can figure out how to make the color changer myself from other scripts I have but I want my color changer to only work with the piece of furniture that you sync the color changer with. That way I could have one color changer for a whole set of furniture with no limits to how many pieces could be edited by the color changer. For example you click the sync button on the color changer and then the next piece of furniture, made to work with the color changer, would be edited by the color changer. That way the scripts would only be listening and sending out messages when you choose to have them do so. I am wondering how possible that is and how much work it might be so I can figure out if I should try and do it myself or hire someone.

Take into account that I can edit scripts and get what I want from them but I can't create my own scripts from scratch usually. 

 

QUOTE From reply 5 as to what I actually want:

I got the demo and it seems it still does a bit much even if it was just the color choices. I was thinking even simpler than that. A lot less color options.


It seems like I might be able to set this up on my own. I can create the script that would be in the object to listen for message when it is touched. Though how could I set up a timer for it to stop listening if the color hasn't changed for a minute or so?


Might someone be able to teach me how I might add a loop that would be a timer to check if the color has changed in the alloted time. If it has changed it would keep listening and if not it would stop listening.

Link to comment
Share on other sites

oo That is quiet the HUD but it is a bit much for what I am wanting. Though if I was to give that kind of control I might as well set the object to mod. I'm more for giving users options but not swamping them with so many. 

I'm just looking to make something simpler in general. 

Thanks though for taking your time to post that though. Let's me know that it is possible. :)

Link to comment
Share on other sites

Mind if I ask how mod it is? It says copy, mod, and texture but does that mean you can actually edit the scripts?

 

Edit: I got the demo and it seems it still does a bit much even if it was just the color choices. I was thinking even simpler than that. A lot less color options. 

It seems like I might be able to set this up on my own. I can create the script that would be in the object to listen for message when it is touched. Though how could I set up a timer for it to stop listening if the color hasn't changed for a minute or so?

Might someone be able to teach me how I might add a loop that would be a timer to check if the color has changed in the alloted time. If it has changed it would keep listening and if not it would stop listening. 

Link to comment
Share on other sites


Syle Devin wrote:

 

Might someone be able to teach me how I might add a loop that would be a timer to check if the color has changed in the alloted time. If it has changed it would keep listening and if not it would stop listening.

Try something like this:

 

float interval =30.0;integer handle;integer offset =24;integer chan;key toucher;key owner;integer Key2Number(key objKey) {	return ((integer)("0x"+llGetSubString((string)objKey,-8,-1)) & 0x3FFFFFFF) ^ 0x3FFFFFFF;}init(){	owner = llGetOwner();	chan = Key2Number(owner);//generate an integer based on the owner's key	chan += offset; // and add the offset to it, in case something else uses the same basic method of generating keys}default{	state_entry()	{		init();	}	changed(integer change)	{		if(change & CHANGED_OWNER){			init();		}	}	touch_start(integer total_number)	{		if(owner == llDetectedKey(0)){// only bother if it's the owner			llResetTime();			toucher = owner;		}	}	touch_end(integer total_number)	{		if (owner == toucher){			if(llGetTime()>1.00){//and only start listening if the owner touches me for more than 1 second				handle == llListen(chan,"","","");//start listening				llSetTimerEvent(interval);//and start the timer			}		}	}	timer()	{		llListenRemove(handle);//stop listening		llSetTimerEvent(0.0);//turn off timer	}	listen(integer channel, string name, key id, string message)	{		if  (llGetOwnerKey(id)==toucher){//only respond if the hud belongs to my owner -- hard to imagine how it can be otherwise, but...			if("Finished"==message){ //if the message is "Finished"				llListenRemove(handle); //stop listening				llSetTimerEvent(0.0);//turn off timer				return;			}			else{				//do colour changing stuff				llSetTimerEvent(interval); // and  restart the timer			}		}	}}

 You can also check in the changed event if the colour has changed (I thought this didn't work when a script changes the colour, since it certainly doesn't with textures, but I've just checked).   So

changed(integer change){		if (change & CHANGED_COLOR){			llSetTimerEvent(30.0);		}	}

 would do it, too, but  I don't see any particular advantage to restarting the timer there instead of in the listen event.

  • Like 1
Link to comment
Share on other sites

That is amazing. I haven't had time to work with it but I will be soon. Also the reason I was thinking for the timer after the color is changed is because I can have the script stop listening and shut down if nothing happens after a period of inactivity. That way the script is not wasting resources if the user hasn't done anything. I never thought of a finish button to send the finish message though. That might be something I could add on top of the auto stop.

Link to comment
Share on other sites

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...