Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Can you have multiple listens?

Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
10-25-2004 08:15
In the same script, can you have separate listens?

If you separate the listens into different states can you have different listens?
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Al Bravo
Retired
Join date: 29 Jun 2004
Posts: 373
10-25-2004 08:31
Yes, you can have multiple llListen() statements. You must figure out which statement triggered the listen() event though.

Yes, you can have different llListen() statements in separate states. And state transitions automatically cancel the listens from the previous state.

Details
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
10-25-2004 08:34
In fact, if you're not careful, you can end up with too many listens, resulting in a script crash.

Its best to keep track of the listen handles returned by llListen(), and do an llListenRemove() on those that are not still necessary. Not only can you crash your script, but listen processing is lag-inducing.

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
Archaegeo Platini
Ancient Earth University
Join date: 12 Aug 2004
Posts: 152
10-25-2004 08:34
Yes, but they all go to the same listen() event for your current state.

Some things to bear in mind....

If you change states in a script, you must redefine any listens in the state_entry for your new state.

Also, you cannot have multiple listens on the same channel, only one per channel, the new filters override the old ones.

Finally, if your going to have an object out all the time thats listening, be sure to make a global integer to assign when you set the listen, so that you can later remove the listen when it doesnt need to be active. Listens are one of the major sim hogs

CODE

integer listenNum;

default
{
state_entry()
{
listenNum = llListen(0, "", "", "");
}
}


Now since listenNum is defined when you make the listen call, you can use llRemoveListen(listenNum) somewhere else in your script that would be appropraite.

I made some items that only listen when touched, and toggle listen back off when touched again. If you want to make it even cleaner, set up a timer call to automatically turn off listens every so often and reset the timer whenever a listen occurs.

Food for thought.
_____________________
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Dean Archaegeo Platini
Ancient Earth University

Courses for the Second Life

secondlife://Sedig/211/46
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
10-25-2004 08:57
From: Archaegeo Platini
Also, you cannot have multiple listens on the same channel, only one per channel, the new filters override the old ones.


BZZT.... Wrong answer! The wiki is your friend.

As of 1.5.4, at least, this is no longer the case. The
llListen() entry on the wiki has a good description of the behavior when there are multiple listens on the same channel. The gist of it all is that multiple llListen()'s on the same channel can result in multiple listen() events being generated.

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
billy Madison
www.SLAuctions.com
Join date: 6 Jun 2004
Posts: 2,175
10-25-2004 08:59
haha, you can have several listens on the same channel think about it. You have the television on a baseball game, the radio on the same game and then your friend calls you on the telephone and has the game playing also and you can hear it in the background not to mention you can listen to it via internet. therefore you have several diff listens on one channel! i guess this doesnt matter because you guys are talking about scripting but im bored and full of jokes. SORRY
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
10-25-2004 09:35
Indeed you can have multiple listens on the same channel. Due to some sloppy scripting on my part, I once created an attachment that would spawn a new listen on every sim-boundary crossing. Needless to say, when the attachment actually received a command, it did it about a zillion times, and promptly crashed the sim. :o
_____________________
- Making everyone's day just a little more surreal -

Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
10-25-2004 10:35
ah, sorry to misword that and get you all off on the wrong track.

What I meant had nothing to do with the chat listen.

What I was talking about was a "link_message" kind of a listen. Sorry I was thinking about how it was working when you talk about the pair of commands that do the linked messaging, one of them listens, and the other one talks... My bad, and sorry to get off on the wrong foot here...

can you have multiple linked messages listening? IE:
CODE

state somestate ()
{
link_message(integer sender_num, integer num, string str, key id)
{
....
}
}

state anotherstate ()
{
link_message(integer sender_num, integer num, string str, key id)
{
....
}
}


...something like that and have them perform different functions?
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
10-25-2004 10:56
Well, link_message is an event, not a function; as far as I know, any given state can have only one instance of an event. If you have multiple states, of course, each one can have a link_message event; however only the link_message event in the state that the script is currently running in will respond to incoming link messages.
_____________________
- Making everyone's day just a little more surreal -

Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
10-25-2004 11:22
Good, because from what I think you've said, I can have a linked message say something to one state waiting for a certain number of events to happen, then call another state which will wait and interpret the linked messages in another way.

Excellent news! Thanks
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
10-26-2004 08:10
From: Cross Lament
Well, link_message is an event, not a function; as far as I know, any given state can have only one instance of an event. If you have multiple states, of course, each one can have a link_message event; however only the link_message event in the state that the script is currently running in will respond to incoming link messages.

Unless the compiler was revamped from last time I scripted, you can indeed have multiple instances of the same event in the same state, but the virtual machine only triggers the first one defined.
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
Thanks again, and OH by the way....
10-27-2004 07:33
I just wanted to say that I'm always impressed with the level of expert help in get in here. It's usually very fast, and accurate, as well as almost always helpful!

I wish I could find this same kind of a forum board for Python. I saw a post by one of the Lindens talking about how he was thinking about implementing Python as a new language for scripting. That sparked my interest, and I was off on a tangent.. (yeah just like this response!) :D

The true point of this reply though, is that I want to thank you all again. Not just this post, but any that I see here, and not just the ones that I have posted in. There are LOTS of good ideas in here! Ok everyone, stand up pat yourselves on the back (and then get back to it!) haha.
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts