Jump to content

DetectedKey using llAvatarOnLinkSitTarget is it possible?


Cindy Kraai
 Share

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

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

Recommended Posts

state_entry()
	{
		llListen(7, "", NULL_KEY, "");
		//with multiple listen channels here
	}
listen(integer chan, string name, key id, string msg)
    {
        if(chan = 7 && llDetectedKey(0) == llAvatarOnLinkSitTarget(3))
        {
			//listens only to the AvatarOnLinkSitTarget
		}
	}

i've been trying this but it doesn't seem to listen and im not sure if im doing it wrong. If there is an easy way please help, if none thanks anyway for viewing this post.

Link to comment
Share on other sites

llDetected* functions don't work in listen() events, but you have the id variable to use instead.

Also, be careful with "=" (assignment) versus "==" (comparison). And personally I'd add a nest of parenthesis around each of the conditions being conjoined with &&, because I never remember operator precedence in different languages.

  • Like 3
Link to comment
Share on other sites

Another way of doing it is, when someone sits down, to open a listener listening only to that avatar.   Then remove the listener when the avatar stands up.    

If I can make the simulator do my filtering for me (which isn't always possible, of course) I will do.   So, something like this fragment: 

integer handle;
integer channel = 7;


default {
	
	changed(integer change){
		if(change & CHANGED_LINK){
			key k = llAvatarOnSitTarget();
			if(k){// if k is a valid key
				llListenRemove(handle);//close any old listeners
				handle = llListen(channel, "",k, "");//open a new listener, listening only to k
			}
			else{//k isn't a valid key, which means there's no one sitting on me, so whoever it was has just stood up
				llListenRemove(handle);//stop listening to whoever it was
			}
		}
	}
}

 

  • Like 3
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2328 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...