Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How do listens work?

Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
10-15-2005 15:29
Okay, this one might seem like an odd one to ask, but it's actually something that could be quite useful to know, so if someone does know or can devise a test to find out then it would really help!

Basically, I want to know how listen commands in script work, I have an idea of how they could work and from this may be able to devise a very simple way to have a LOT of items listening for commands from a single control item. Let me explain, first of all how I think listens might work.

Let us suppose that when a listen command is created, it takes the channel number (if one is supplied) and creates an entry for itself in a little listing for that channel (or a generic list if no channel was specified). This little list contains a note of all objects listening to that channel, and what they are listening out for (if anything in particular like certain players or messages).
When a message is sent to a channel, SL looks up the listing for that channel and for each listen command it finds there, looks to see if the message matches any of them.
If it does then that command is triggered for that script.

So, in theory a listen command on a channel that is no frequently used (ie not channel zero) actually causes ZERO processing overhead beyond creating a little listing for it.

If this is how the listen command works this way, then would it be feasible to set up a system as follows:

Say I have a number of objects (say for argument's sake these are pose balls since for my idea they would be), each of these creates a listen command on an obscure channel, looking for the command 'show' or 'hide'.
Somewhere nearby is another object, when it is touched it says (or shouts as appropriate) the correct command on this same obscure channel.

As such there is zero overhead except the brief processing when the item is touched, but it allows a large number of objects to be controlled by a single mouse-click.

Now, I could be wrong and listens work completely differently, but every other methd I can think of is insanely ineffecient so I'm hoping my implimentation is the correct one.

This is mainly just food for thought in case anyone has needed to do the same thing, but it's would be quite useful for me to know because I want to use it in my home (once I've bought land) but want it to be as lag-free as possible while still having lots of stuff
Zeno Concord
To infinity, and beyond!
Join date: 28 Mar 2005
Posts: 51
10-15-2005 15:53
Sounds reasonable to me. That's how I would implement passive listens.

However, you may be missing the other half of the equation. It is not the listening that is expensive, unless a lot of things are talking on the channel that is being listened to, and consequently the listen handler must be invoked each time. It is the talking that is expensive, especially llShout, because the system must find all the scripts that are within the required distance (100m for a shout) that are listening on the channel. How should it efficiently do that lookup for every communication, especially when objects are moving?
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
10-15-2005 17:57
doesnt matter, the doof next door will put up a mall with 50,000 vending machines all with listens on channel 0 and sensor and per second timers
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
10-15-2005 18:22
Heh, bit of a pecimist eh? In that case I'll have to buy my own sim for my shop deep in the forest... heh.

I don't think the shouting will be much of a big concern, since it isn't going to be invoked very often, once to show the poseballs and make them active at the same time, once more to switch them off/make them invisible once I'm done. Really just so there aren't a load of ugly pose-balls ruining my furniture when I just want to lounge about or talk to guests :P
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
10-15-2005 19:09
im that way becuase eventho i got land almost 4 sims away from the cloest telehub that! is exactly what is butted up against me =/
jester Knox
Sculpter of Water
Join date: 22 Apr 2004
Posts: 204
10-15-2005 19:11
this thread may help shed some light on what you are trying to figure out
/invalid_link.html

also for something like poseballs why not use touch and link messages? no lag and no commands to remember.


jester


.
_____________________
people tell me my fountains are cool, come check them out at JesAma Fountains, Alviso (190,45) or if you arent in SL try Gigas (secondserver.net) or SLBoutique to shop for my products.
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
10-16-2005 00:21
From: Haravikk Mistral
...once to show the poseballs and make them active at the same time, once more to switch them off/make them invisible once I'm done. Really just so there aren't a load of ugly pose-balls ruining my furniture...
Haravikk, are you aware that you can put sit targets and animations directly into the furniture, without needing poseballs at all?
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
10-16-2005 04:56
Yeah I thought of that too actually, but I'd like to be able to have the furniture useable normally when the pose-balls are switched off, and only used for erm...other things when the pose-balls are visible and in their active state; ie the little remote control object would switch them between states with its messages, so if someone accidentally clicked on it it would just result in them floating in the air a bit. In fact it could even have them sit properly if I use the sit target functions to position them correctly, making it as though the pose-balls aren't even there until switched on!

Jester, although touch and link-messages do what is needed, it would either need to do it for a single set of pose-balls at a time (ie I'd have to click all of them to hide them all) or require a massive set of linked pose-balls.
I'm going for something where you can stick a remote on your wall, and drop new pose-balls in whenever you feel like and it'll just work. Similarly if you already have a set of pose-balls and drop in a remote, it'll take control of the show/hide function (at least for compatible sets listening on that channel).

If I'm thinking through this correctly then it could actually be quite a nifty little thing to set-up, could even be combined with other items to create an entirely different mood for a room when switched on.
Judah Jimador
Registered User
Join date: 13 Mar 2005
Posts: 230
Bubbling Emailer?
10-16-2005 08:20
Say you had a switch on your wall which held a notecard with the UUID's of all your poseballs.

It also had a very tiny phantom, temp-on-rez object in inventory.

When you touched the switch, it walked through the notecard, rezzing one of these little thingies right inside itself for each line it found, and passing the next UUID via llWhisper on some obscure channel. The channel would increment for each thingie rezzed during a cycle, and would be passed to the newly-rezzed object via the on_rez event.

The rezzed thingie would clear its listener, email its assigned target a TOGGLE command, and then llDie().

So you've got a little burst of listen/chat activities (one at a time, cycling very quickly) when you touch the button. But no noticeable hits on your property's prim allowance (because of temp-on-rez), and no activity at all until the wall switch is touched by somebody it recognizes, except for periodic mail checks in the poseballs, which should be timed as far apart as you're willing to wait for the room to cycle...say once every couple of minutes? Worst case, unless you've got 900 of these suckers going, I'd think a 30- to 60-second mail check cycle would give a reasonable balance between responsiveness and Good Sim Citizenship.

A buddy of mine gave me the idea here.

-- jj
jester Knox
Sculpter of Water
Join date: 22 Apr 2004
Posts: 204
10-16-2005 10:11
maybe if you arent in a hurry just use e-mail to all the poseballs, or preferably maybe use e-mail to say the couch and it link messages to the poseballs on it (same should go for using listens that way there are only a handful of them, 1 for each piece of furniture).


jester


.
_____________________
people tell me my fountains are cool, come check them out at JesAma Fountains, Alviso (190,45) or if you arent in SL try Gigas (secondserver.net) or SLBoutique to shop for my products.