Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Newbie Question turning listen on/off

Jose Rainbow
Registered User
Join date: 18 Sep 2005
Posts: 6
10-22-2005 08:29
I have been playing with a script that started as a visitor list. I've added some proximity detect/report with distance stuff. Now I want to be able to turn it on and off without killing the object.

The scan rate is set as a global variable with float rate = 1.0; if I try to go into the listen section and listen for "obj off" and reset rate to 0 it doesn't turn the listener off.

Any hints would be appreciated.
Eric Boyer
SL Mentor / Live Helper
Join date: 13 Sep 2005
Posts: 55
10-22-2005 08:33
llListenRemove() mabey might work
Hinkley Baldwin
Registered User
Join date: 13 May 2004
Posts: 77
10-22-2005 08:34
Hi Jose,

I'm assuming you're using llSensorRepeat(). To stop it, just use llSensorRemove().
Jose Rainbow
Registered User
Join date: 18 Sep 2005
Posts: 6
10-22-2005 10:25
From: Hinkley Baldwin
Hi Jose,

I'm assuming you're using llSensorRepeat(). To stop it, just use llSensorRemove().


Thanks - I'll try that.
Jose Rainbow
Registered User
Join date: 18 Sep 2005
Posts: 6
10-22-2005 10:25
From: Eric Boyer
llListenRemove() mabey might work


Looks like what I need
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
10-22-2005 13:12
Jose - this would be a great place to use states.
CODE
default
{
state_entry()
{
llListen(1, "", llGetOwner(), "scan on");
}

listen(integer channel, string name, key id, string message)
{
state scanning;
}
}

state scanning
{
state_entry()
{
llListen(1, "", llGetOwner(), "scan off");
llSensorRepeat("", NULL_KEY, AGENT, 90.0, PI, 10.0);
}

listen(integer channel, string name, key id, string message)
{
state default;
}

sensor(integer num_detected)
{
integer i;
for (i=0 ; i<num_detected ; ++i)
llOwnerSay(llDetectedName(i));
}
}
switching states automatically removes both the listens and the sensor scans.
Notice that the listens are filtered by channel, avatar key and message. Prefer "tight" listens to reduce lag.
To further reduce lag, consider using touch to switch the object on or off, rather than voice commands.
Jose Rainbow
Registered User
Join date: 18 Sep 2005
Posts: 6
10-22-2005 14:52
From: Hinkley Baldwin
Hi Jose,

I'm assuming you're using llSensorRepeat(). To stop it, just use llSensorRemove().


What I did is use llSensorRemove() for off and llResetScript() to turn it back on. I bcan still view or reset the list in either mode.

Thanks for the help.
Jose Rainbow
Registered User
Join date: 18 Sep 2005
Posts: 6
10-22-2005 14:55
From: Ben Bacon
Jose - this would be a great place to use states.
CODE
default
SNIPPED FOR BREVITY


Didn't see this until I had it working already. I'll try to remember this for next time.

Thanks.