Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Why Does This Sensor Script Only Work 4 Me

Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
06-27-2007 21:41
Below is a script that, when placed in an object and the object touched, returns a list of avatar names as a dialog menu. Then when a name is selected, broadcasts it on channel 0 with a preceeding message. Can anyone tell me why, when I pass the object to another person it doesn't broadcast the message when they select an avatar name from the dialog menu???

Thanks
Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
heres the script
06-27-2007 21:44
integer channel = -10;
string menuText = "Select your target:";
list avatarsDetected = [ ];
list keysDetected = [ ];

useKey(key targetKey)
{
// This is where you "do something" with that key. I dunno whatYOU plan to do with it
// in my demo in world, I passed it to a particle beam. There's some issues with that
// since the particle target range seems to be the client's draw distance.
// but if you wanted to rez a follower, or whatever, you'd do that here.
}

default
{
state_entry()
{
llListen(channel, "", llGetOwner(), "";);
}

listen(integer channel, string name, key id, string message)
{
integer listPos = llListFindList(avatarsDetected, (list)message);
useKey(llList2Key(keysDetected, listPos));
llSay(0, "i love u " + message);
}

touch_start(integer duration)
{
llSensor("", NULL_KEY, AGENT, 100, PI);
}

sensor(integer numDetected)
{
if (numDetected > 12) numDetected = 12;
integer nextStep;
string nextAvatarName;
string nextAvatarKey;
avatarsDetected = [ ];
keysDetected = [ ];
for (nextStep = 0; nextStep < numDetected; nextStep++)
{
nextAvatarName = llDetectedName(nextStep);
nextAvatarKey = llDetectedKey(nextStep);
if (llStringLength(nextAvatarName) > 24) nextAvatarName = llGetSubString(nextAvatarName, 0, 23);
avatarsDetected = (avatarsDetected=[]) + avatarsDetected + nextAvatarName;
keysDetected = (keysDetected=[]) + keysDetected + nextAvatarKey;
}
llDialog(llGetOwner(), menuText, avatarsDetected, channel);
}
}
Steve Memotech
Registered User
Join date: 27 Mar 2007
Posts: 20
06-27-2007 21:45
From: Mako Davidson
Below is a script that, when placed in an object and the object touched, returns a list of avatar names as a dialog menu. Then when a name is selected, broadcasts it on channel 0 with a preceeding message. Can anyone tell me why, when I pass the object to another person it doesn't broadcast the message when they select an avatar name from the dialog menu???

Thanks



Where is the script?
Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
sorry here it is
06-27-2007 21:52
When they rez the object it they click on it and get the dialog box. It just doesn't respond with a message and instead lags them???
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
06-27-2007 22:02
From: Mako Davidson

state_entry()
{
llListen(channel, "", llGetOwner(), "";);
}

When you saved this script, the script got your key as the owner and there was never chance to get anyone else's.
This script is needed to reset after changing owner.
_____________________
:) Seagel Neville :)
Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
ok thanks Seagel
06-27-2007 22:08
Can you please adivese how to fix this?? Do I add an on_rez event and reset the script there??
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
06-27-2007 22:31
Yes, exactly, you're right.
CODE
on_rez(integer reset)
{
llResetScript();
}

Or
CODE
changed(integer change)
{
if(change & CHANGED_OWNER)
{
llResetScript();
}
}

You can put down llListen(channel, "", llGetOwner(), "";); insted of llResetScript();
_____________________
:) Seagel Neville :)
Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
Thanks Mate Worked Like A Charm :) !!!
06-27-2007 22:39
Thanks Mate Worked Like A Charm :) !!!