llListen question
|
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
|
10-10-2004 16:53
Hi, I've recently been working on scripted pets that follow your AV around... I am having a problem with llListen - If I use the following line: llListen(1,"",llGetOwner(),""  ; ... and then I give a copy to someone else, the pet doesn't listen for them, it listens and hears commands from me! So, I'm using : llListen(1,"","",""  ; ... which just hears commands from everyone, which some people like and has worked well.... BUT, does anyone know why using llGetOwner() isn't working for me and apparently listening for the creator instead of the owner?
|
Chris Knox
Member
Join date: 22 Apr 2004
Posts: 40
|
10-10-2004 16:59
have the script ResetScript on rez
|
Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
|
10-10-2004 20:45
From: Chris Knox have the script ResetScript on rez No no no no no. Use the llListen(1,"",NULL_KEY,""  ; one, but in your listen() event, put in a if(id == llGetOwner()) conditional. Then you don't have to reset the script at all.
_____________________
</sarcasm>
|
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
|
10-10-2004 20:49
Your problem is caused because you are the owner when you set up the listen using llListen(1,"",llGetOwner(),""  one way around it is as Chris says resetting the script whenever the object rezzes. A better way is to use llListen(1,"","",""  and filter in your listen event as so- if( id != llGetOwner() ) { return; } everything already in your listen
|
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
|
10-11-2004 18:24
Nice. That did the trick. Everyone was right, thank you all much!
|
Zuzi Martinez
goth dachshund
Join date: 4 Sep 2004
Posts: 1,860
|
10-11-2004 18:48
would one of you mind explaining why this method is better than resetting the script? seems to me it would be better to reset and only listen for the owner if you only want the owner to be able to use it, rather than listening to the whole world and filtering out everyone but the owner everytime but what do i know?
|
Meiyo Sojourner
Barren Land Hater
Join date: 17 Jul 2004
Posts: 144
|
10-11-2004 19:21
From: Zuzi Martinez would one of you mind explaining why this method is better than resetting the script? seems to me it would be better to reset and only listen for the owner if you only want the owner to be able to use it, rather than listening to the whole world and filtering out everyone but the owner everytime but what do i know? I think it depends on the situation... in this case, the listen is already only paying attention to channel 1, and so the event isn't going to be called up because of regular chat. If you have a script that needs to listen on the general chat channel... and there's a possibility of it changing owners... then resetting the script may be a better option as long as you don't mind the data stored by the script being wiped each time you rez the script. Although, you could do something like this.... (code not tested at all) key known_owner = ""; default { state_entry() { known_owner = llGetOwner(); llListen(0, "", known_owner, ""); }
on_rez(integer start_param) { if (llGetOwner() != known_owner) llResetScript(); }
// .... and then the rest of the code blah blah blah
} Let me just say for the record tho that I do not like using Listens on the general chat channel unless they are on a timer.... -Meiyo
_____________________
I was just pondering the immortal words of Socrates when he said... "I drank what??"
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
10-11-2004 20:15
> would one of you mind explaining why this method is better than resetting the script? seems to me it would be better to reset and only listen for the owner if you only want the owner to be able to use it, rather than listening to the whole world and filtering out everyone but the owner everytime but what do i know? Resetting the script is sorta kludgy; it generally implies you're not really sure what needs to be reset, otherwise you'd just reset those bits. Also, there are often reasons why you *dont* want your scripts to be reset, eg persistent data, things like that. At that point, you have two choices: the more correct choice, and the lazy choice. Lazy choice is to listen to everything on channel zero and filter. More correct choice is to remove the old listener and recreate a new listener in on_rez and state_entry: integer iChannelListener = 0; integer iChannel = 0;
GenericInit() { ListenRemove( iChannelListener ); iChannelListener = llListen( iChannel, 0, llGetOwner(), "" ); }
... state_entry() { GenericInit(); } on_rez(...) { GenericInit(); }
Azelda P.S. I use the lazy way errrr... often.
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
10-12-2004 10:07
I guess I do not know much about permissions, but if you rez something, don't you have to be the owner to do that?
OOPS...
The answer to that can be NO! In the case where someone gives you something and the item *IS* owned by you, but the script does not know it yet, because the script never really stops running when it goes back into inventory.
I know most people here will have already known that, but for clarity and to help others realize it, there it is. Does that help anyone?
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|