Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Making the HUD work

RaptonX Zorger
Registered User
Join date: 26 Jan 2006
Posts: 79
04-12-2006 18:08
Ok, I can get it all to work with command lines, but how can I get it to trigger the listen scripts with the objects in the HUD, note that i have the listen script set to listen to owner, so maybe that is why it won't work, is there a way to make it listen to both owner and the HUD. I don't exactly want the listen to be open to other people though.
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
04-12-2006 19:50
use something like this in your listen event on a channel
CODE
if ((id != llGetOwner()) && (llGetOwnerKey(id) != llGetOwner()))
return;

if the id is not the owner & the key of the object is not the owner it will return
-LW
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-13-2006 00:31
What about setting a secret long negative number for the channel?
_____________________
:) Seagel Neville :)
Adriana Caligari
Registered User
Join date: 21 Apr 2005
Posts: 458
04-13-2006 01:40
CODE


integer channel = (integer)llFrand( 99999 ) + 99999;
// if you must use a negative - personally never bother
channel = channel * -1;
integer lhandle = llListen( channel,"","","" );

Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-13-2006 03:43
hmm... a random number is good usually, but I don't think that it is appropriate for this matter. And you can do this, too.

// channel = channel * -1;
integer lhandle = llListen( -channel,"","","" );
_____________________
:) Seagel Neville :)
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
04-13-2006 03:50
From: Lightwave Valkyrie
use something like this in your listen event on a channel
CODE
if ((id != llGetOwner()) && (llGetOwnerKey(id) != llGetOwner()))
return;

if the id is not the owner & the key of the object is not the owner it will return
-LW

IIRC, llGetOwnerKey when applied to an avatar's key returns the same key, so you can just use if (llGetOwnerKey(id) != llGetOwner()) return;
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
04-13-2006 03:55
As far as communication goes, incidentally, what I did for the last object-related HUD I built was:

1. pick a particular odd channel e.g. -1231234
2. have the HUD listen on that for any key
3. the object whispers on that channel
4. the HUD picks up that whisper, checks to see if the owners are the same, and if so, cancels the old listen and starts another one specifically for that object's key

That way you don't have to check each time that the owners are the same, and your listen is less laggy as it's tied to one key - important with rapidly-changing HUD information, like an ammunition count in this case. On the other hand you have to make sure that the HUD resets itself on a regular basis as otherwise you have to restart it manually every time you rez the gun again. In most cases I'd just use the owner comparison method.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-13-2006 04:17
The HUD seems to recieve the both command's methods, personal chat and object's chat. So if you dare to use owner check...

if ((id != llGetOwner()) || (llGetOwnerKey(id) != llGetOwner())) return;

?

From: Ordinal Malaprop
IIRC, llGetOwnerKey when applied to an avatar's key returns the same key, so you can just use if (llGetOwnerKey(id) != llGetOwner()) return;
:eek: I didn't read this carefully.... sorry. Ordinal may be right.
This means... llGetOwnerKey(llGetOwner()) == llGetOwner(); ?
_____________________
:) Seagel Neville :)