Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSay issues

Maury Lehane
Registered User
Join date: 28 Feb 2005
Posts: 3
05-05-2006 12:07
heres the deal .. i have a hud attachment ive made to control features on a gun i also made this hud simply repeats the objects name of the pressed button over a chat channel then the listen command picks it up so if i have a listen for a draw command i just name the button draw ... now the problem is i want thisto work with the hud but not with anything else and i also note if some one else is wearing my guns and hud that my hud affects there gun .. is there a way to make wach hud and gun set interact only with each other if they have the same owner ? or some other method of preventing other objects or my own from affecting guns of the same type owned by some one else ?
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
05-05-2006 12:12
From: Maury Lehane
heres the deal .. i have a hud attachment ive made to control features on a gun i also made this hud simply repeats the objects name of the pressed button over a chat channel then the listen command picks it up so if i have a listen for a draw command i just name the button draw ... now the problem is i want thisto work with the hud but not with anything else and i also note if some one else is wearing my guns and hud that my hud affects there gun .. is there a way to make wach hud and gun set interact only with each other if they have the same owner ? or some other method of preventing other objects or my own from affecting guns of the same type owned by some one else ?


In the listen event, call llGetOwnerKey() on the speaking object's key, and check it matches llGetOwner().
Maury Lehane
Registered User
Join date: 28 Feb 2005
Posts: 3
05-05-2006 12:26
From: Yumi Murakami
In the listen event, call llGetOwnerKey() on the speaking object's key, and check it matches llGetOwner().

umm
im not sure what you mean i took a look at the getownerkey command and i dont really understand how it works
prak Curie
----------
Join date: 4 Jun 2004
Posts: 346
05-05-2006 14:48
From: Maury Lehane
im not sure what you mean i took a look at the getownerkey command and i dont really understand how it works


My advice is poor. Please see the next post for someone who actually knows what they are talking about.

---- Begin Bad Advice Block ----
http://secondlife.com/badgeo/wakka.php?wakka=llListen

The third argument you pass to llListen() should be llGetOwner().
----- End Bad Advice Block -----
_____________________
-prak
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
05-05-2006 15:11
To clarify what Yumi said...

In the listen event, you get a key parameter, which is the key of the object/avatar that spoke. In this case, this will be the key of the HUD. What you need to check is to see if the owner of the HUD, is the same as the owner of the object that's listening (presumably a gun).

So inside the gun, you know your own owner - that's llGetOwner, pretty simple. But you also need to find the owner of a different object, the HUD. You have the HUD's key, so you use llGetOwnerKey to find the HUD's owner. If the two match, you know that the command came from the right HUD. If they don't match, it's someone else's HUD that issues the command.

So, something like this...

CODE

listen(integer channel, string name, key id, string message)
{
// That "key id" is the key of the object that spoke, i.e. the HUD
// So first thing we do is see if the HUD's owner is the same as our owner


if (llGetOwnerKey(id) != llGetOwner())
{
// Mismatch - my owner is different from the HUD's owner
// Someone else's HUD - ignore
return;
}

// Do whatever you would normally do
}


Hope that helps.

From: someone
The third argument you pass to llListen() should be llGetOwner().


I don't think that will work, because the HUD will speak with its own key, not the owner's key. That would work if it were a dialog menu (which speaks with the avatar's key).
prak Curie
----------
Join date: 4 Jun 2004
Posts: 346
05-05-2006 15:50
From: Ziggy Puff
I don't think that will work, because the HUD will speak with its own key, not the owner's key. That would work if it were a dialog menu (which speaks with the avatar's key).

Right you are. My mistake.
_____________________
-prak
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
05-06-2006 11:48
Just a nit, but it is more readable, code-wise: :)

CODE

listen(integer channel, string name, key id, string message)
{
// That "key id" is the key of the object that spoke, i.e. the HUD
// So first thing we do is see if the HUD's owner is the same as our owner

if (llGetOwnerKey(id) == llGetOwner())
{
// Do whatever you would normally do
}

}
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
05-06-2006 12:50
From: Talarus Luan
Just a nit, but it is more readable, code-wise: :)

CODE

listen(integer channel, string name, key id, string message)
{
// That "key id" is the key of the object that spoke, i.e. the HUD
// So first thing we do is see if the HUD's owner is the same as our owner

if (llGetOwnerKey(id) == llGetOwner())
{
// Do whatever you would normally do
}

}
Ah dunno; Ah often finds
CODE
if (!test) {
crashGracefully;
}
else {
tonsOfStuff;
};
ta be easier ta read than
CODE
if (test) {
tonsOfStuff;
}
else {
crashGracefully;
};
...especially when tonsOfStuff includes this same structure recursively.

Not always; it depends on which is longer, tonsOfStuff or crashGracefully. Ah says `tis easier ta read with th` shorter one first.

Jes` ma L$0.02 worth;), an` strictly a matter of personal opinion. No flames intended, so please don`t flame back. Toodle-oo!
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
05-06-2006 18:55
You could set up a randomly numbered channel, 1/ 2 billion choices!!

1. Set up a variable at the start of your script (before default)
CODE

integer gChannel; // g shows this is a global variable - just a convention




2. Set up the channel number somewhere in your startup code:

CODE

gChannel = -(integer)llFrand(0x7FFFFF00) - 255;


3. call the dialog, set up the listen and then listen to the hud:

CODE

llDialog (llGetOwner (), "Prompt", menuListMove, gChannel);
llListen( gChannel, "", "", "" );



CODE

listen( integer rchannel, string name, key id, string message ) {
// respond to hud here

}