|
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
08-14-2007 01:11
Hey all, I'm just wondering if what I'm doing is the best way for a script in a HUD attachment of mine to talk to its buddy attached to my avatar's chest. What I'm doing is having the chest attachment ask the HUD a question so it can get the HUD's key and create a more specific listen, something like this: From: someone //chest attachment script default { attach(key attached) { if (attached != NULL_KEY) //object has been attached { handle = llListen(myChan, "HUD", NULL_KEY, "well, thankyou"  ; llWhisper(HUDchan, "hows it going?"  ; } else //deteached llListenRemove(handle); } listen(integer channel, string name, key id, string message) { if (HUDsKey == NULL_KEY) //don't have HUD's key yet, then we must be listening on first listen { llListenRemove(handle); HUDsKey = id; handle = llListen(myChan, "HUD", HUDsKey, ""  } else { //info from HUD } } } There are 3 things I want to know: 1.) Is this the best way to do get the key in order to get a more specific listen 2.) Is there a way to tell which llListen is currently operating instead of my semi-lame if (HUDsKey == NULL_KEY) test 3.) Are my llListenRemove's clean? Is there only one listen open at a time? I always get worried about missing one and every time someone attaches the object for it to add another listen on until there are 100s of the same listens lagging the sim... nerve racking. Anyway thanks for any input in advance 
_____________________
Other than that, Mrs. Lincoln, how was the play?
|
|
Simnelia Petrichor
Registered User
Join date: 10 Feb 2006
Posts: 35
|
08-14-2007 01:30
I'd say the downside of this is that it doesn't check the owner of the HUD, so if someone nearby was wearing the same thing your respective attachments could conceivably end up talking to each other.
If you're worried about multiple listens you can always just have the script reset when it's attached.
|
|
Nyoko Salome
kittytailmeowmeow
Join date: 18 Jul 2005
Posts: 1,378
|
08-14-2007 01:50
what simnelia said  plus it looks like your listenremove is in the right place, before calling up the second listen (but be sure to do the same before the first new listen too  doesn't hurt.
_____________________
 Nyoko's Bodyoils @ Nyoko's Wears http://slurl.com/secondlife/Centaur/126/251/734/ http://home.comcast.net/~nyoko.salome2/nyokosWears/index.html "i don't spend nearly enough time on the holodeck. i should go there more often and relax." - deanna troi
|
|
Jotheph Nemeth
Registered User
Join date: 9 Aug 2007
Posts: 142
|
08-14-2007 03:33
I usually like to throw the owner key in on the handshaking, but I like the idea of closing and re-opening the listen once it gets the hud key. Very smart.
|
|
Scott Tureaud
market base?
Join date: 7 Jun 2007
Posts: 224
|
08-14-2007 09:34
listen(integer channel, string name, key id, string message) { ` if(llDetectedOwner(0)==LLgetowner) //something like this will let you listen for objects only from the owner not on second life right now so it's just a guestimation ` {
` } }
|
|
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
08-14-2007 12:16
i took most of the meat of my code out for this example because I have some stuff I don't want all of SL to see. The real code already includes checks that both are owned by the same person. Thanks for all the ideas 
_____________________
Other than that, Mrs. Lincoln, how was the play?
|
|
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
|
08-14-2007 23:22
I've been running a similar thing with my HUDs for a while now. It's nice removing the "open" listen and tightening it up with a listen to a specific object-key only. Just have to make sure you reset the listen to an open state anytime interaction from a differently keyed object is possible.
_____________________
--AeonVox--Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
|