Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Default action when llListen no longer hears message

Kliger Dinkin
Registered User
Join date: 22 Apr 2006
Posts: 46
05-21-2008 03:55
I have a script that llListens to instructions for mapping textures from another nearby object. When I'm outside the range of the llSay (or llShout etc...) message, I want to map a default texture (that I can hard code into the script). In other words, when the object is no longer hearing a message, how can I get it to default back to a specific texture?

Can someone help me get pointed in the right direction? Thanks in advance.

Listening script :
<php>
default {
state_entry() {
string objDesc = llGetObjectDesc();
integer textureChannel = (integer)objDesc;
llListen(textureChannel, "", "", "";);
}

listen(integer textureChannel, string name, key id, string msg) {
string textTextureId = msg;
key textureId = (key)textTextureId;
llSetTexture(textureId, ALL_SIDES);
}
}
</php>

Sending script:
<php>
float time = 3.0;

default {
state_entry() {
llSetText("",<1,1,1>,0);
llSetTimerEvent(time);
}
timer() {
integer number = llGetInventoryNumber(INVENTORY_TEXTURE);
integer choice = (integer)llFrand(number);
string tName = llGetInventoryName(INVENTORY_TEXTURE, choice);
key textureId = llGetInventoryKey(tName);
string textTextureId = (string)textureId;
if (tName != "";) {
llSetTexture(textureId, ALL_SIDES);
string objDesc = llGetObjectDesc();
integer textureChannel = (integer)objDesc;
llWhisper(textureChannel,textTextureId);
}
}
on_rez (integer start_param) {
llResetScript();
}
}
</php>
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
05-21-2008 04:20
as I see it you need a timer event to decide if the speaker is idle.
Or better, a sensor to see when the speaker is out of reach.

Happy scripting
_____________________
From Studio Dora
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
05-21-2008 04:41
that other object could use llRegionSay() to be heard within the entire sim.

Then you would not have to worry about getting out of range.
Kliger Dinkin
Registered User
Join date: 22 Apr 2006
Posts: 46
05-21-2008 04:48
From: Squirrel Wood
that other object could use llRegionSay() to be heard within the entire sim.

Then you would not have to worry about getting out of range.

I actually want to be able to move out of range... it's acting like a sensor also. But I need to default back to a material when I'm out of chat range.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
05-21-2008 05:48
Use a sensor then, that scans for you within chat range. As soon as you leave this range, you change the texture...

// 20 Meters is the max-distance of an llSay-Command
// 100 Meters is the max-distance of an llShout-Command

llSensorRepeat ("", llGetOwner(), AGENT, 20.0, PI, 5.0);

no_sensor(){
llSetTexture(...);
}
Kliger Dinkin
Registered User
Join date: 22 Apr 2006
Posts: 46
05-21-2008 13:28
From: Haruki Watanabe
Use a sensor then, that scans for you within chat range. As soon as you leave this range, you change the texture...

// 20 Meters is the max-distance of an llSay-Command
// 100 Meters is the max-distance of an llShout-Command

llSensorRepeat ("", llGetOwner(), AGENT, 20.0, PI, 5.0);

no_sensor(){
llSetTexture(...);
}


That's what I ended up doing.
Question: Does "no_sensor" work without being preceded by a "sensor" event. It doesn't seem to be working for me, so I put in a (useless) "sensor." Just wondering...
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
05-22-2008 00:31
From: Kliger Dinkin
That's what I ended up doing.
Question: Does "no_sensor" work without being preceded by a "sensor" event. It doesn't seem to be working for me, so I put in a (useless) "sensor." Just wondering...


Hmm, good question. I would think that it would, but maybe not. If putting in a null sensor event fixes it, then I guess you have the answer.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
05-22-2008 00:47
Simple answer: no. You need a sensor otherweise the sensor()/no_sensor()-events won't be triggered.