llRegionSay with HUD - but listening only to HUD owner
|
|
Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
|
10-10-2007 08:05
I've been trying to script a listener, that listens to certain commands. These commands come from a HUD, that I wear. Example: I press a HUD button and the HUD says: llRegionSay(99,"listen only to owner"  ; The listener is in a prim somewhere on the sim. If it receives "listen only to owner", it should say: llOwnerSay("Owner I heard you"  ; The problem I'm having now, is that if i give my HUD to a friend, the listener does not notice, it's not my HUD the commands come from, even though I used: llGetOwnerKey(id) in the listener to identify the owner. I guess its not a big deal, but something must be wrong here. Thanks for helping.
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
10-10-2007 08:12
llGetOwnerKey(id) will return the owner of the object which triggered the listen event. Since you gave this HUD to your friend it will return your friend's Key and not your own.
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
10-10-2007 10:15
What key is the listener listening for? Yours, your friend's, or NULL_KEY?
Hint: put llInstantMessage() calls in a bunch of places to show what's happening, and be sure to print all the relevant function arguments.
|
|
Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
|
10-10-2007 14:27
The listener goes like this: llListen(99,"",llGetOwner(),""  ; So, if the HUD says: llRegionSay(99,"message"  ; the listener does not react. I guess the problem might be, that it's not me saying the message, but the HUD. If i get close to the listener and say /99 message, it works. Any suggestions to make this work? Thanks in advance...
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
10-10-2007 15:02
OK, you transferred the HUD to your friend. Did you also transfer the listener?
|
|
Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
|
10-10-2007 16:06
No, only the HUD
by the way...if I use llGetOwner() in the listener, it doesnt work with my own HUD as well...it simply doesnt react at all...if I use llGetOwner(id)...it works..but also with the transferred HUD.
|
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
10-11-2007 00:02
Have the HUD rename itself to something that either incorporates the owner key or name.
Like, HUD_Ludvaig_Lindman
and have your listener listen for an object with that exact name.
Though bear in mind that anyone can name a prim accordingly and communicate with the listener that way.
Also, you may want to use negative chat channels to prevent avatars from talking to your listener directly.
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
10-11-2007 02:51
llListen(chan,name,key,message)
If you set the key of llListen to llGetOwner() then whenever the llListen is called it will set a filter to listen to only that key. The key is unique to the owner, no objects or other avatars will have this key, not even your own objects so your HUD would not be able to communicate with the object. Instead, set the key to "", so that it does not filter by key. You can use Squirrel's idea of renaming the HUD to a predetermined value which the name value of llListen will filter for, i.e. (in the hud) string objectname = llGetObjectName(); llSetObjectName("nandNerdHUD"); llRegionSay(-234,"activate"); llSetObjectName(objectname);
(in the object) llListen(-234,"nandNerdHUD","","");
Also, a useful trick for keeping your objects from taking commands from other people is to use the following in your listen event: listen(integer chan, string name, key id, string msg) { if (llGetOwnerKey(id) == llGetOwner()) { //do stuff } }
What this does is check the id of the object/person which triggered the listen event (i.e. it's passed all the filter criteria) and confirms that the owner of the speaking object is also the owner of the listening object. If id is the owner's key then it will also pass the test.
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
|
10-11-2007 08:30
I solved it this way: The HUD fetches the key of its owner using string objectowner = llGetOwner(); and says: llRegionSay(channel,"message"+objectowner). The listener listens to "message"+objectowner. Thanks for helping 
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
10-11-2007 10:58
if you don't actually need the name of the av wearing the hud, why not have it listen for "hudname" on some negative channel?
if you have more than one hud wearer you could use llGetObjectDetails to retrieve the name of the hud owner from the listen ID
|