|
Cegaiel Shan
Registered User
Join date: 12 Apr 2007
Posts: 9
|
06-23-2007 18:28
Hi, I planning on several objects that will work independently, but all listen to the same channel. If I use: llListen(channel, "", NULL_KEY, ""  ; then everything works fine, but I'm concerned that an object next to it, will hear the message on the same channel (they all need to use same channels for simplicity) and they will all do the task. I tried using llListen(channel, "", llGetKey(), ""  ; thinking that it will register a listen for the object that is speaking, which is what I want, but it doesn't hear the object when it speaks. How can I register a listen to respond to when the object speaks? Heres a mini portion of the script to get an idea: integer channel = 100; key avatar;
default { state_entry() { llSetTimerEvent(60); llListen(channel, "", llGetKey(), ""); \\ this is the problem I'm having, this line }
timer() { llDialog(avatar,"\nDo you want to keep camping?.",["YES","NO"],channel); }
listen(integer channel, string name, key id, string message) { llOwnerSay(message); \\ this is just so i can verify if the listen is working correctly
if (message == "NO") { llUnSit(avatar); } }
}
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
06-23-2007 18:43
In the sample code, the llListen() is for a dialog response from the avatar. Instead of llGetKey() of the object itself, the listen should be for avatar (the value of which is presumably being set elsewhere in the code, from llAvatarOnSitTarget() in changed() CHANGED_LINK).
[Edit: Just in passing, in the real script, the llSetTimerEvent() call should also presumably be in the changed() CHANGED_LINK event handler.]
|
|
Cegaiel Shan
Registered User
Join date: 12 Apr 2007
Posts: 9
|
Thanks
06-23-2007 19:14
Yeah, I do have llSetTimer in the correct area: changed(integer change) { if(change == CHANGED_LINK) { avatar = llAvatarOnSitTarget(); if(avatar != NULL_KEY) { llSetTimerEvent(idle_interval); handle = llListen(channel, "", avatar, ""  ; } else { llSetTimerEvent(0); llListenRemove(handle); } but registering the listen to the Avatar worked, thanks. I do also now see in the Wiki's llDialog screen that there is a note that the listen can't distinquish if the person is speaking or if the dialog is speaking. Since I saw text coming from object name on the chat screen, I was assuming that the object key is what was speaking... But everything is working great now, tyvm.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
06-24-2007 05:47
From: Cegaiel Shan I do also now see in the Wiki's llDialog screen that there is a note that the listen can't distinquish if the person is speaking or if the dialog is speaking. Since I saw text coming from object name on the chat screen, I was assuming that the object key is what was speaking... But everything is working great now, tyvm. Just to clarify, a dialog NEVER speaks, it will always be the avatar who selected an item on the dialog. The dialog mechanism is just to allow you to select items quickly ratehr than typing it in. Repsonding to your first post, to make an object listen only to another specific object you need to supply the llListen with the key of the other object. Obtaining the key can be the fun part. One method is to hard code it, either in the script itself or into a notecard that the object reads on start up or change. Another method is to have the main object spawn/rez the secondary objects and pass them the channel number as part of the rez event. Then the spawner says something on that channel and the listener will have its key and can recreate the listen for just that specific object.
_____________________
I'm back......
|