Jump to content

Touch Say only to avatar who touched


Loki Eliot
 Share

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

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

Recommended Posts

Here's a simple example that should get you going:

key kToucher;                       //-- who's touching us?integer iMenuChannel = -99;  //-- menu listener channel (start at -99 by default)list lMainMenu = ["YES", "NO", "MAYBE"];//-----------------------------------------------------------------//----- subroutine doMainMenu()
//----- we make this a separate subroutine so that we can easily expand on it later
//----- if it becomes necessary to do additional work like determining whether the
//----- person is authorized to invoke the menu, or presenting different menus for
//----- different users, etc.
doMainMenu(){ llDialog(kToucher, "Make a selection", lMainMenu, iMenuChannel);}//-----BEGIN default() STATE---------------------------------------default{ //----------------------------------------------------------------- //----- event-handler touch_start() occurs whenever the object is //----- touched by an avatar. touch_start(integer iTotalNumber) { kToucher = llDetectedKey(0); //--- get the key of who touched us doMainMenu(); //--- now call up the menu in response to the user's touch } //----- END touch_start()------------------------------------------}//---- END default() STATE-----------------------------------------

(This could probably be simplified even further, but I copied it from an existing source I had lying around.  Yes, my comments tend to be verbose, but it helps me remember what the heck I was trying to accomplish with a given section of code when I have to come back to it six months later! :) )



 

Link to comment
Share on other sites

HI you could also have it say different things if the toucher is in your group or what ever thought id put this here never know who may need it :)

    touch_start(integer num_detected)    {        integer x;        key     detectedKey;         for (x = 0; x < num_detected; x += 1)        {            detectedKey = llDetectedKey(x);            if (detectedKey == llGetOwner())            { llInstantMessage(detectedKey," Your the owner");                              }            else if (llSameGroup(detectedKey))                        { llInstantMessage(detectedKey," Your the in my group");                        }           else if (detectedKey == partner)            {  llInstantMessage(detectedKey," Your my partner");

 

Link to comment
Share on other sites

Anyway, I think I misread what the OP was trying to do; the code I posted above would be to present a menu to the toucher.  To just say something to them in the chat channel, here's the simplest possible method:

default{  touch_start(integer iTotalNumber)  {    llInstantMessage(llDetectedKey(0), "STOP TOUCHING ME!");  }}

 

 

  • Like 1
Link to comment
Share on other sites

The trouble with llInstantMessage() is that it will stall your script for 2s.

The newer function llRegionSayTo() does not have any artificial delay and has a number of other advantages (can be addressed to an object or avatar, if addressed to an avatar can be heard by all that avatar's attachments).

default{	touch_end(integer HowMany){		while(HowMany--){			if(0 == HowMany){llRegionSayTo(llDetectedKey(HowMany), 0, "You were the 1st to touch me");}			else if(1 == HowMany){llRegionSayTo(llDetectedKey(HowMany), 0, "You were the 2nd to touch me");}			else if(2 == HowMany){llRegionSayTo(llDetectedKey(HowMany), 0, "You were the 3rd to touch me");}			else{llRegionSayTo(llDetectedKey(HowMany), 0, "You were the " + (string) (HowMany + 1) + "th to touch me");}		}	}}

 

Link to comment
Share on other sites


Indio Quinnell wrote:

Good to know --  I didn't know about the new llRegionSayTo() function; it doesn't seem to be mentioned at the LSL Wiki where I normally get my scripting info from, so it must be a
very
recent addition to the language.  I'll make a note of that for future reference, thanks!

Really lslwiki.net has only had minor edits for over a year, it is missing lots of new fuctionality and changes. It is best used as a secondary source now.

Link to comment
Share on other sites

Yeah, me too. It's horribly out of date by now, though, and misleading.  I do miss some of it's folksy style.  It was written for more of an amateur audience than today's wiki -- friendlier for the beginner.  Unfortunately, though, some of that also makes it more ambiguous in places.  All in all, I think it was a good reference for its time, but no longer.

Link to comment
Share on other sites

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