Jump to content
trivis

Listen or Timed Say for Two object to recognise eachother

Recommended Posts

Dear all,

Perhaps you have an answer to my question. 

I have two objects. One is a clothing and the other one is a hud. The hud is for changing the texture of the clothing. So clothing would be worn "often" and the hud "sometimes".

To make the texture-exchange as easy as possible, I have two scripting options for both objects to see eachother. One is that the clothing has a listener that is always open and reacts with llRegionSayTo. The other options is that the clothing has a timer, for let's say every 10 or 15 seconds and the hud has a listener.

After the two object "see" eachother the exchange of information can start.

Will there be a best option of those two options?

Thanks in advance,

Trivis

Edited by trivis
  • Like 1

Share this post


Link to post
Share on other sites

I would take advantage of the fact that if you call  llRegionSayTo(id, channel, message) and the id is the UUID of an avatar, then that message will be heard by a script in any article that avatar is wearing  (or sitting on) that is listening on the right channel.

So choose a long negative integer that nothing else on the region is going to be using and have the articles simply use llRegionSayTo(kOwnerUUID, iVeryNegativeChannel, strMessage).    That way nothing else is going to hear them. 

If you want to be really sure, you can, in addition, do something like 

	listen(integer channel, string name, key id, string message)
	{
		if(llGetOwnerKey(id)==llGetOwner()){
			//the object sending the message belongs to the owner of this script
			//so process it
		}
		//else it doesn't, so ignore it
	}

That way it's only going to hear your objects.

Share this post


Link to post
Share on other sites

Thanks Innula!

This is how i have done it so far. Have a long negative channel based on the ownerkey and clothingobject. Works all fine. This means that the listener in the clothing is ALWAYS listening... most of the time for 'nothing'.

So I was thinking if the clothing would not listen at first but use a timer to llRegionSayTo and let the hud listen, wouldnt that be more efficient? 

Thanks again for your swift response, Innula.

Trivis

Share this post


Link to post
Share on other sites

While you're completely correct that keeping open listeners when you don't need to is generally discouraged, I don't think it's an issue in this particular case.

The reason is that what really hits the simulator's resources is having to decide which messages to send to which object when there are several objects on the region listening on the same channel, and then each of the scripts that receives the message having to decide what, if anything, to do about the message.

So in this example, if you're using a long negative channel then nothing else on the region will be sending messages on it, so the simulator won't need to decide which objects should receive it.   If you were listening on -1 it would probably be a different story, but if it's -3258485 then there shouldn't be anything to worry about.    Furthermore, when an object sends a message on that channel using llRegionSayTo the simulator doesn't do any checks involving other objects -- it simply checks who or what the uuid corresponds to and, if it's an avatar on the region, what the avatar is wearing or sitting on that's listening to that channel.

So I really wouldn't worry about using timers and things.   I understand what you're trying to do, and applaud it, but in this particular case I don't think it's necessary and, in fact, I think you'd probably use more simulator resources trying to solve the problem than by simply ignoring it.

  • Like 1

Share this post


Link to post
Share on other sites

You can not optimise things that way.

You have a script with one listener that is completely inactive all the time. (as long as the hud isn't used)
And you want to optimize that with a script that triggers a timer regularly and burns cpu cycles that way.

If you want to optimize things you need numbers but not guesses. In this case you can compare both scripts in the management console which requires you to be an estate manager.
Even then, the load is so low you won't see much here so you need to put 100 scripts into each object and then check and compare the script load.

That gives numbers and a base to decide about optimizations. In this case it's a waste of time and energy anyways.

A while ago I made some tests and even if you have a few 1000 listeners you will not notice any problems. If you trigger them all at the same time 1000 times in a row then you will notice an effect :) the script execution of the sim will recover shortly after that load btw. :)

  • Like 1

Share this post


Link to post
Share on other sites

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.


×
×
  • Create New...