|
Nerolus Mosienko
Registered User
Join date: 3 Aug 2006
Posts: 145
|
02-22-2007 22:32
Hello I've got a "holster" type script going on. One object in hand One object connected to a belt I've created a hud that speaks on channel 88, it tells the scripts inside both objects to show or hide. I've given this item to a few friends, but when one of us clicks show or hide on the hud, everyones items are shown or hidden. Here is the scripts, any help is greatly appreciated! In the object: default { state_entry() { llListen(88, "", NULL_KEY, ""); }
listen(integer c, string name, key id, string msg) { if (msg == "Show") llSetAlpha(0.0, ALL_SIDES); else if (msg == "Hide") llSetAlpha(1.0, ALL_SIDES); } }
In the HUD: default {
touch_start(integer total_number) { llWhisper(88, "Show"); } }
^^^alternative is "hide" for the other button
|
|
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
|
02-22-2007 22:57
In the object: default { state_entry() { llListen(88, "", NULL_KEY, ""); }
listen(integer c, string name, key id, string msg) { if( llGetOwnerKey( id ) == llGetOwner() ) { if (msg == "Show") llSetAlpha(0.0, ALL_SIDES); else if (msg == "Hide") llSetAlpha(1.0, ALL_SIDES); } } }
_____________________
- Making everyone's day just a little more surreal -
Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
|
|
Nerolus Mosienko
Registered User
Join date: 3 Aug 2006
Posts: 145
|
02-22-2007 23:14
Aha! So thats where llGetOwner goes... Thank you for curing my noobism! 
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
another appraoch
02-23-2007 08:51
Generate a random integer between 10000 and 99999 ( or whatever). Use channel 88 to let the related objects know. use that random number as the communciation channel.
Yes, yoo might still get a duplicate once in awhile, but it is unlikely. You could code the objects to detect a duplicate, and change automatically, too.
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
me again
02-23-2007 08:53
i noteice that Cross puts the check for owner in the listen event handler.
You could also put it in the llListen(). Then the object would only hear the owner, and the check in the listen(){} would not be needed.
|
|
RobbyRacoon Olmstead
Red warrior is hungry!
Join date: 20 Sep 2006
Posts: 1,821
|
02-23-2007 09:11
From: Lee Ponzu i noteice that Cross puts the check for owner in the listen event handler. You could also put it in the llListen(). Then the object would only hear the owner, and the check in the listen(){} would not be needed. While this is a great idea for the general case of listening to the owner, in this case the items are listening to a HUD, so this would not work and the check in the listen event is still necessary.
|