Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Fix Listen?

Ozark Mayo
Registered User
Join date: 3 Jun 2008
Posts: 18
10-21-2009 18:19
THIS HAS BEEN RESOLVED.



---





I received a script from someone that allows me to link a door to a build, and not have the build rotate.

Here is my issue. I commented out the touch section, because I want the actual opening done by a hud, or another object.

The door will only open if I am near it, and I am not even sure if a command from someone other than me will work.

Is there a way to force this door script to listen to an object, lets say a HUD, from a far distance away?

I have tried, and it will not do it. I used the LLRegionSay(chan,mess) to broadcast the word "open" on the listen channel, and the door did nothing.

What am I missing?

The script is below.

Thanks,

Ozark



string doorOpenSound = "";
string doorCloseSound = "";
string confirmedSound = "69743cb2-e509-ed4d-4e52-e697dc13d7ac";
string accessDeniedSound = "58da0f9f-42e5-8a8f-ee51-4fac6c247c98";
string doorBellSound = ""; // Setting to empty stops door announcements too.
float autoCloseTime = 6; // 0 seconds to disable auto close.
integer allowGroupToo = FALSE; // Set to FALSE to disallow same group access to door.
list allowedAgentUUIDs = ["9769c4d4-7674-4bd1-a604-3395b58a6e16"]; // Comma-separated, quoted list of avatar UUIDs who are allowed access to this door.
integer listenChannel = 89702;


//------------------------------------------------------
// Leave the rest of the settings alone, these are
// handled by the script itself.
//------------------------------------------------------
integer isLocked = FALSE; // Only when the door is locked do the permissions apply.
integer isOpen = TRUE;
vector openPos = ZERO_VECTOR;
rotation openRot = ZERO_ROTATION;
vector openScale = ZERO_VECTOR;
vector closedPos = ZERO_VECTOR;
rotation closedRot = ZERO_ROTATION;
vector closedScale = ZERO_VECTOR;
key openerKey = NULL_KEY;
key closerKey = NULL_KEY;
integer isSetup = FALSE;
integer listenHandle = 0;
string avatarName = "";

mySayName(integer channel, string objectName, string message)
{
string name = llGetObjectName();
llSetObjectName(objectName);
llSay(0, "/me " + message);
llSetObjectName(name);
}

mySay(integer channel, string message)
{
string name = llGetObjectName();
llSetObjectName("Door";);
llSay(0, message);
llSetObjectName(name);
}

myOwnerSay(string message)
{
string name = llGetObjectName();
llSetObjectName("Door";);
llOwnerSay(message);
llSetObjectName(name);
}

mySoundConfirmed()
{
if (confirmedSound != "";)
{
llTriggerSound(confirmedSound, 1.0);
}
}

mySoundAccessDenied()
{
if (accessDeniedSound != "";)
{
llTriggerSound(accessDeniedSound, 1.0);
}
}

myGetDoorParams()
{
isSetup = FALSE;
if (llSubStringIndex(llGetObjectDesc(), "door;";) == 0 && llSubStringIndex(llGetObjectName(), "door;";) == 0)
{
list nameWords = llParseString2List(llGetObjectName(), [";"], []);
list descWords = llParseString2List(llGetObjectDesc(), [";"], []);
if (llGetListLength(nameWords) != 4 || llGetListLength(descWords) != 4)
{
myOwnerSay("The door prim's name and/or description has invalid syntax and/or number of parameters. Delete the door prim's name and description and setup the door prim again.";);
}
else
{
openPos = (vector)llList2String(nameWords, 1);
openRot = (rotation)llList2String(nameWords, 2);
openScale = (vector)llList2String(nameWords, 3);
closedPos = (vector)llList2String(descWords, 1);
closedRot = (rotation)llList2String(descWords, 2);
closedScale = (vector)llList2String(descWords, 3);
isSetup = TRUE;
}
}
}

mySetDoorParams(vector openPos, rotation openRot, vector openScale, vector closedPos, rotation closedRot, vector closedScale)
{
llSetObjectName("door;" +
(string)openPos + ";" +
(string)openRot + ";" +
(string)openScale);
llSetObjectDesc("door;" +
(string)closedPos + ";" +
(string)closedRot + ";" +
(string)closedScale);
isSetup = TRUE;
}

integer myPermissionCheck(key id)
{
integer hasPermission = FALSE;
if (isLocked == FALSE)
{
hasPermission = TRUE;
}
else if (llGetOwnerKey(id) == llGetOwner())
{
hasPermission = TRUE;
}
else if (allowGroupToo == TRUE && llSameGroup(id))
{
hasPermission = TRUE;
}
else if (llListFindList(allowedAgentUUIDs, [(string)id]) != -1)
{
hasPermission = TRUE;
}
return hasPermission;
}

myOpenDoor()
{
isOpen = FALSE;
myToggleDoor();
}

myCloseDoor()
{
isOpen = TRUE;
myToggleDoor();
}

myToggleDoor()
{
if (isSetup == FALSE)
{
myOwnerSay("The door prim has not been configured yet. Please read the usage instructions in the door script.";);
}
else if (llGetLinkNumber() == 0 || llGetLinkNumber() == 1)
{
myOwnerSay("The door prim must be linked to at least one other prim and the door prim must not be the root prim";);
}
else
{
isOpen = !isOpen;
if (isOpen)
{
if (doorBellSound != "";)
{
llTriggerSound(doorBellSound, 1.0);
if (avatarName != "";)
{
mySayName(0, avatarName, "is at the door.";);
avatarName = "";
}
}
if (doorOpenSound != "";)
{
llTriggerSound(doorOpenSound, 1.0);
}
llSetPrimitiveParams([ PRIM_POSITION, openPos, PRIM_ROTATION, ZERO_ROTATION * openRot / llGetRootRotation(), PRIM_SIZE, openScale ]);
// Door API.
llMessageLinked(LINK_SET, 255, "cmd|door|opened", NULL_KEY);
}
else
{
if (doorCloseSound != "";)
{
llTriggerSound(doorCloseSound, 1.0);
}
llSetPrimitiveParams([ PRIM_POSITION, closedPos, PRIM_ROTATION, ZERO_ROTATION * closedRot / llGetRootRotation(), PRIM_SIZE, closedScale ]);
// Door API.
llMessageLinked(LINK_SET, 255, "cmd|door|closed", NULL_KEY);
}

llSetTimerEvent(0.0);
if (isOpen == TRUE && autoCloseTime != 0.0)
{
llSetTimerEvent(autoCloseTime);
}
}
}

default
{
state_entry()
{
listenHandle = llListen(listenChannel, "", NULL_KEY, "";);
myGetDoorParams();
}

// touch_start(integer total_number)
// {
// if (myPermissionCheck(llDetectedKey(0)) == TRUE)
// {
// avatarName = llDetectedName(0);
// myToggleDoor();
// }
// else
// {
// mySoundAccessDenied();
// }
// }

timer()
{
myCloseDoor();
}

link_message(integer sender_num, integer num, string str, key id)
{
// Door API. The API is here in case you want to create PIN entry keypads or whatever.
if (num == llGetLinkNumber())
{
if (str == "cmd|door|doOpen";)
{
myOpenDoor();
}
else if (str == "cmd|door|doClose";)
{
myCloseDoor();
}
}
if (str == "cmd|door|discover";)
{
llMessageLinked(LINK_SET, 255, "cmd|door|discovered|" + (string)llGetKey(), id);
}
}

listen(integer channel, string name, key id, string message)
{
// Performance note: it's quicker to compare the strings than to compare permissions each time anyone says anything on this channel.
if (message == "open";)
{
if (myPermissionCheck(id) == TRUE)
{
// Only open the door if the person is quite close to this door.
openerKey = id;
closerKey = NULL_KEY;
avatarName = name;
llSensor(name, id, AGENT, 5.0, TWO_PI);
}
else
{
mySoundAccessDenied();
}
}
else if (message == "close";)
{
if (myPermissionCheck(id) == TRUE)
{
openerKey = NULL_KEY;
closerKey = id;
avatarName = name;
// Only close the door if the person is quite close to this door.
llSensor(name, id, AGENT, 5.0, TWO_PI);
}
else
{
mySoundAccessDenied();
}
}
else if (message == "lock";)
{
if (myPermissionCheck(id) == TRUE)
{
isLocked = TRUE;
mySoundConfirmed();
}
else
{
mySoundAccessDenied();
}
}
else if (message == "unlock";)
{
if (myPermissionCheck(id) == TRUE)
{
isLocked = FALSE;
mySoundConfirmed();
}
else
{
mySoundAccessDenied();
}
}
else if (message == "/door opened" && llSubStringIndex(llGetObjectName(), "door;";) == -1)
{
if (llGetOwnerKey(id) == llGetOwner())
{
mySoundConfirmed();
openPos = llGetLocalPos();
openRot = llGetLocalRot();
openScale = llGetScale();
isOpen = TRUE;
if (! (closedPos == ZERO_VECTOR && closedRot == ZERO_ROTATION && closedScale == ZERO_VECTOR))
{
mySetDoorParams(openPos, openRot, openScale, closedPos, closedRot, closedScale);
}
}
else
{
mySoundAccessDenied();
}
}
else if (message == "/door closed" && llSubStringIndex(llGetObjectDesc(), "door;";) == -1)
{
if (llGetOwnerKey(id) == llGetOwner())
{
mySoundConfirmed();
closedPos = llGetLocalPos();
closedRot = llGetLocalRot();
closedScale = llGetScale();
isOpen = FALSE;
if (! (openPos == ZERO_VECTOR && openRot == ZERO_ROTATION && openScale == ZERO_VECTOR))
{
mySetDoorParams(openPos, openRot, openScale, closedPos, closedRot, closedScale);
}
}
else
{
mySoundAccessDenied();
}
}
}

sensor(integer num_detected)
{
if (openerKey != NULL_KEY)
{
integer i;
for (i = 0; i < num_detected; i++)
{
if (llDetectedKey(i) == openerKey && myPermissionCheck(llDetectedKey(i)) == TRUE)
{
myOpenDoor();
}
}
openerKey = NULL_KEY;
}
else
{
integer i;
for (i = 0; i < num_detected; i++)
{
if (llDetectedKey(i) == closerKey && myPermissionCheck(llDetectedKey(i)) == TRUE)
{
myCloseDoor();
}
}
closerKey = NULL_KEY;
}
}

//------------------------------------------------------
// Uncomment the following code if you particularly want
// collisions to affect the door state.
//------------------------------------------------------

// collision_start(integer num_detected)
// {
// integer i;
// for (i = 0; i < num_detected; i++)
// {
// if (myPermissionCheck(llDetectedKey(i)) == TRUE)
// {
// avatarName = llDetectedName(i);
// myOpenDoor();
// }
// else if (llDetectedType(i) & AGENT)
// {
// mySoundAccessDenied();
// }
// }
// }

} // End of default state and end of scri
Ozark Mayo
Registered User
Join date: 3 Jun 2008
Posts: 18
10-21-2009 18:22
After posting it here, I re-read through it, and found a spot that had this...

// Only open the door if the person is quite close to this door.
openerKey = id;
closerKey = NULL_KEY;
avatarName = name;
llSensor(name, id, AGENT, 5.0, TWO_PI);

--

I completely missed this, and maybe after posting the code somewhere it was easier to read therefore making me catch this spot.

Sorry!

--O
Ozark Mayo
Registered User
Join date: 3 Jun 2008
Posts: 18
10-21-2009 18:39
EDIT: Now I can shout and it will open. I just set the distance for the sensor to 4096.0. (Although I can probably just comment it out.)

But I try using an object, and nothing happens.

Any suggestions?

--ORIGINAL MESSAGE--

I disabled both the sensors, but it still will not open or close.

Again, I have to be missing something.

--Ozark
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
10-22-2009 00:27
I think -- though I have not been able to test this -- that if you alter
CODE
if (llDetectedKey(i) == openerKey && myPermissionCheck(llDetectedKey(i)) == TRUE)
{
myOpenDoor();
}
to

CODE
if (llDetectedKey(i)==llGetOwnerKey(openerKey)&&myPermissionCheck(llDetectedKey(i)) == TRUE){
myOpenDoor();
}
that should do the trick.

What my revised version means, in English, is "if the uuid of the avatar I detected is the same as that of the owner of whatever's just told me to open, and the permissions check says it's ok, then open the door."

If you run llGetOwnerKey() on an avatar, it returns that avatar's uuid (if you run it on something belonging to the avatar, it returns the avatar's key, too, obviously).

The reason -- a reason, anyway -- you were having problems is that the door was detecting the avatar and then hearing from a HUD, and had no way of knowing that the HUD was anything to do with the avatar, since their UUIDs are different.

ETA -- you will, of course, need to turn the sensors back on, or it won't know who llDetectedKey(i) is.

ETA 2 -- I've now had a closer look at this.. If I've properly understood what you want to do, I think you also need, in the listen event, to check
CODE
if (myPermissionCheck(llGetOwnerKey(id)) == TRUE)


The door is set up on the assumption that an avatar will be talking to it. You want to change things so that either the avatar or something belonging to the avatar can talk to it. So you need to go through your code, changing all references to the uuid detected or heard by the script to llGetOwnerKey(uuid). That returns the avatar's uuid, whether the uuid you're checking is that of the avatar or something the avatar owns,
Ozark Mayo
Registered User
Join date: 3 Jun 2008
Posts: 18
10-22-2009 13:07
From: Innula Zenovka


ETA 2 -- I've now had a closer look at this.. If I've properly understood what you want to do, I think you also need, in the listen event, to check
CODE
if (myPermissionCheck(llGetOwnerKey(id)) == TRUE)


Do I need to replace every "if (myPermissionCheck(id) == TRUE)" with the "if (myPermissionCheck(llGetOwnerKey(id)) == TRUE)"?

I know a little about scripting. Like syntax (its pretty generic for all languages (or so it seems)), since I am going for a computer science major. some of this LSL stuff is a bit above me right now.

--Ozark
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
10-22-2009 16:47
From: Ozark Mayo
Do I need to replace every "if (myPermissionCheck(id) == TRUE)" with the "if (myPermissionCheck(llGetOwnerKey(id)) == TRUE)"?

I know a little about scripting. Like syntax (its pretty generic for all languages (or so it seems)), since I am going for a computer science major. some of this LSL stuff is a bit above me right now.

--Ozark

Yes, i think you will need to change them all.

Basically, "if (myPermissionCheck(id) == TRUE)" means, "if the uuid I'm checking is on my approved list".

And, while it's not literally what it means, "if (myPermissionCheck(llGetOwnerKey(id)) == TRUE)" is equivalent to saying, "if the uuid I'm checking is on the approved list or is that of an item that belongs to someone who is on the list".

While there are bits of the code (like the sensor event) where you're only going to get the avatar's uuid and not that of the hud (so the change is redundant there), I think you'll find it simplest to replace your test with mine throughout, since my test will always work for the avatar as well as for the avatar's hud, and this way you don't need to worry about which you're likely to detect if you're not sure.
Ozark Mayo
Registered User
Join date: 3 Jun 2008
Posts: 18
10-22-2009 17:04
I think I replaced everything. The object I am using to try and open/close the door is not attached. It listens to me on channel 10, and then says whatever I say on the 89702 channel (llRegionSay(chan,mess)). I have used this radio script before.

I tried opening the door again and nothing.

I want you to know, Innula, that I appreciate the help. If by the end it doesn't work, I may go with a different script, but I really want to have the doors linked so customers don't have to fuss with things they don't need to fuss with.

Again, thank you.

Posted below is the code I modified with your test, and I replaced what I needed to. I may have missed one again.

--

string doorOpenSound = "";
string doorCloseSound = "";
string confirmedSound = "69743cb2-e509-ed4d-4e52-e697dc13d7ac";
string accessDeniedSound = "58da0f9f-42e5-8a8f-ee51-4fac6c247c98";
string doorBellSound = ""; // Setting to empty stops door announcements too.
float autoCloseTime = 0; // 0 seconds to disable auto close.
integer allowGroupToo = FALSE; // Set to FALSE to disallow same group access to door.
list allowedAgentUUIDs = ["9769c4d4-7674-4bd1-a604-3395b58a6e16"]; // Comma-separated, quoted list of avatar UUIDs who are allowed access to this door.
integer listenChannel = 89702;


//------------------------------------------------------
// Leave the rest of the settings alone, these are
// handled by the script itself.
//------------------------------------------------------
integer isLocked = FALSE; // Only when the door is locked do the permissions apply.
integer isOpen = TRUE;
vector openPos = ZERO_VECTOR;
rotation openRot = ZERO_ROTATION;
vector openScale = ZERO_VECTOR;
vector closedPos = ZERO_VECTOR;
rotation closedRot = ZERO_ROTATION;
vector closedScale = ZERO_VECTOR;
key openerKey = NULL_KEY;
key closerKey = NULL_KEY;
integer isSetup = FALSE;
integer listenHandle = 0;
string avatarName = "";

mySayName(integer channel, string objectName, string message)
{
string name = llGetObjectName();
llSetObjectName(objectName);
llSay(0, "/me " + message);
llSetObjectName(name);
}

mySay(integer channel, string message)
{
string name = llGetObjectName();
llSetObjectName("Door";);
llSay(0, message);
llSetObjectName(name);
}

myOwnerSay(string message)
{
string name = llGetObjectName();
llSetObjectName("Door";);
llOwnerSay(message);
llSetObjectName(name);
}

mySoundConfirmed()
{
if (confirmedSound != "";)
{
llTriggerSound(confirmedSound, 1.0);
}
}

mySoundAccessDenied()
{
if (accessDeniedSound != "";)
{
llTriggerSound(accessDeniedSound, 1.0);
}
}

myGetDoorParams()
{
isSetup = FALSE;
if (llSubStringIndex(llGetObjectDesc(), "door;";) == 0 && llSubStringIndex(llGetObjectName(), "door;";) == 0)
{
list nameWords = llParseString2List(llGetObjectName(), [";"], []);
list descWords = llParseString2List(llGetObjectDesc(), [";"], []);
if (llGetListLength(nameWords) != 4 || llGetListLength(descWords) != 4)
{
myOwnerSay("The door prim's name and/or description has invalid syntax and/or number of parameters. Delete the door prim's name and description and setup the door prim again.";);
}
else
{
openPos = (vector)llList2String(nameWords, 1);
openRot = (rotation)llList2String(nameWords, 2);
openScale = (vector)llList2String(nameWords, 3);
closedPos = (vector)llList2String(descWords, 1);
closedRot = (rotation)llList2String(descWords, 2);
closedScale = (vector)llList2String(descWords, 3);
isSetup = TRUE;
}
}
}

mySetDoorParams(vector openPos, rotation openRot, vector openScale, vector closedPos, rotation closedRot, vector closedScale)
{
llSetObjectName("door;" +
(string)openPos + ";" +
(string)openRot + ";" +
(string)openScale);
llSetObjectDesc("door;" +
(string)closedPos + ";" +
(string)closedRot + ";" +
(string)closedScale);
isSetup = TRUE;
}

integer myPermissionCheck(key id)
{
integer hasPermission = FALSE;
if (isLocked == FALSE)
{
hasPermission = TRUE;
}
else if (llGetOwnerKey(id) == llGetOwner())
{
hasPermission = TRUE;
}
else if (allowGroupToo == TRUE && llSameGroup(id))
{
hasPermission = TRUE;
}
else if (llListFindList(allowedAgentUUIDs, [(string)id]) != -1)
{
hasPermission = TRUE;
}
return hasPermission;
}

myOpenDoor()
{
isOpen = FALSE;
myToggleDoor();
}

myCloseDoor()
{
isOpen = TRUE;
myToggleDoor();
}

myToggleDoor()
{
if (isSetup == FALSE)
{
myOwnerSay("The door prim has not been configured yet. Please read the usage instructions in the door script.";);
}
else if (llGetLinkNumber() == 0 || llGetLinkNumber() == 1)
{
myOwnerSay("The door prim must be linked to at least one other prim and the door prim must not be the root prim";);
}
else
{
isOpen = !isOpen;
if (isOpen)
{
if (doorBellSound != "";)
{
llTriggerSound(doorBellSound, 1.0);
if (avatarName != "";)
{
mySayName(0, avatarName, "is at the door.";);
avatarName = "";
}
}
if (doorOpenSound != "";)
{
llTriggerSound(doorOpenSound, 1.0);
}
llSetPrimitiveParams([ PRIM_POSITION, openPos, PRIM_ROTATION, ZERO_ROTATION * openRot / llGetRootRotation(), PRIM_SIZE, openScale ]);
// Door API.
llMessageLinked(LINK_SET, 255, "cmd|door|opened", NULL_KEY);
}
else
{
if (doorCloseSound != "";)
{
llTriggerSound(doorCloseSound, 1.0);
}
llSetPrimitiveParams([ PRIM_POSITION, closedPos, PRIM_ROTATION, ZERO_ROTATION * closedRot / llGetRootRotation(), PRIM_SIZE, closedScale ]);
// Door API.
llMessageLinked(LINK_SET, 255, "cmd|door|closed", NULL_KEY);
}

llSetTimerEvent(0.0);
if (isOpen == TRUE && autoCloseTime != 0.0)
{
llSetTimerEvent(autoCloseTime);
}
}
}

default
{
state_entry()
{
listenHandle = llListen(listenChannel, "", NULL_KEY, "";);
myGetDoorParams();
}

// touch_start(integer total_number)
// {
// if (myPermissionCheck(llDetectedKey(0)) == TRUE)
// {
// avatarName = llDetectedName(0);
// myToggleDoor();
// }
// else
// {
// mySoundAccessDenied();
// }
// }

timer()
{
myCloseDoor();
}

link_message(integer sender_num, integer num, string str, key id)
{
// Door API. The API is here in case you want to create PIN entry keypads or whatever.
if (num == llGetLinkNumber())
{
if (str == "cmd|door|doOpen";)
{
myOpenDoor();
}
else if (str == "cmd|door|doClose";)
{
myCloseDoor();
}
}
if (str == "cmd|door|discover";)
{
llMessageLinked(LINK_SET, 255, "cmd|door|discovered|" + (string)llGetKey(), id);
}
}

listen(integer channel, string name, key id, string message)
{
// Performance note: it's quicker to compare the strings than to compare permissions each time anyone says anything on this channel.
if (message == "open";)
{
if (myPermissionCheck(llGetOwnerKey(id)) == TRUE)
{
openerKey = id;
closerKey = NULL_KEY;
avatarName = name;
llSensor(name, id, AGENT, 4096.0, TWO_PI);
}
else
{
mySoundAccessDenied();
}
}
else if (message == "close";)
{
if (myPermissionCheck(llGetOwnerKey(id)) == TRUE)
{
openerKey = NULL_KEY;
closerKey = id;
avatarName = name;
// Only close the door if the person is quite close to this door.
llSensor(name, id, AGENT, 4096.0, TWO_PI);
}
else
{
mySoundAccessDenied();
}
}
else if (message == "lock";)
{
if (myPermissionCheck(llGetOwnerKey(id)) == TRUE)
{
isLocked = TRUE;
mySoundConfirmed();
}
else
{
mySoundAccessDenied();
}
}
else if (message == "unlock";)
{
if (myPermissionCheck(llGetOwnerKey(id)) == TRUE)
{
isLocked = FALSE;
mySoundConfirmed();
}
else
{
mySoundAccessDenied();
}
}
else if (message == "/door opened" && llSubStringIndex(llGetObjectName(), "door;";) == -1)
{
if (llGetOwnerKey(id) == llGetOwner())
{
mySoundConfirmed();
openPos = llGetLocalPos();
openRot = llGetLocalRot();
openScale = llGetScale();
isOpen = TRUE;
if (! (closedPos == ZERO_VECTOR && closedRot == ZERO_ROTATION && closedScale == ZERO_VECTOR))
{
mySetDoorParams(openPos, openRot, openScale, closedPos, closedRot, closedScale);
}
}
else
{
mySoundAccessDenied();
}
}
else if (message == "/door closed" && llSubStringIndex(llGetObjectDesc(), "door;";) == -1)
{
if (llGetOwnerKey(id) == llGetOwner())
{
mySoundConfirmed();
closedPos = llGetLocalPos();
closedRot = llGetLocalRot();
closedScale = llGetScale();
isOpen = FALSE;
if (! (openPos == ZERO_VECTOR && openRot == ZERO_ROTATION && openScale == ZERO_VECTOR))
{
mySetDoorParams(openPos, openRot, openScale, closedPos, closedRot, closedScale);
}
}
else
{
mySoundAccessDenied();
}
}
}

sensor(integer num_detected)
{
if (openerKey != NULL_KEY)
{
integer i;
for (i = 0; i < num_detected; i++)
{
if (llDetectedKey(i)==llGetOwnerKey(openerKey)&&myPermissionCheck(llDetectedKey(i)) == TRUE)
{
myOpenDoor();

}
}
openerKey = NULL_KEY;
}
else
{
integer i;
for (i = 0; i < num_detected; i++)
{
if (llDetectedKey(i)==llGetOwnerKey(closerKey)&&myPermissionCheck(llDetectedKey(i)) == TRUE)
{
myCloseDoor();
}
}
closerKey = NULL_KEY;
}
}

//------------------------------------------------------
// Uncomment the following code if you particularly want
// collisions to affect the door state.
//------------------------------------------------------

// collision_start(integer num_detected)
// {
// integer i;
// for (i = 0; i < num_detected; i++)
// {
// if (myPermissionCheck(llDetectedKey(i)) == TRUE)
// {
// avatarName = llDetectedName(i);
// myOpenDoor();
// }
// else if (llDetectedType(i) & AGENT)
// {
// mySoundAccessDenied();
// }
// }
// }

} // End of default state and end of script
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
10-22-2009 17:52
Sorry, I had clearly still not looked closely enough at your script's logic. You will also, I think, need to change this,
CODE
if (myPermissionCheck(llGetOwnerKey(id)) == TRUE)
{
openerKey = id;
closerKey = NULL_KEY;
avatarName = name;
llSensor(name, id, AGENT, 4096.0, TWO_PI);
}
at the start of the listen event, to:
CODE
if (myPermissionCheck(llGetOwnerKey(id)) == TRUE) 
{
openerKey = llGetOwnerKey(id); // openerKey has to be an avatar, and llGetOwnerKey(id) ensures it is
closerKey = NULL_KEY;
avatarName = llKey2Name(openerKey); // get the avatar's name
llSensor(avatarName, openerKey, AGENT, 4096.0, TWO_PI); // and look for the avatar who has spoken to us or who owns the object that's spoken
}


Again, if an avatar has spoken, my changes are redundant, but if it's the avatar's hud, then this has the sensor looking for the owner of the hud rather an avatar who doesn't exist.

See how that works. If it doesn't, I'll take it to bits in world tomorrow and kick it till it does.
Ozark Mayo
Registered User
Join date: 3 Jun 2008
Posts: 18
10-22-2009 18:13
I will give her a try tomorrow.

Again, thanks for the help.

(I will have a gift for you when we get it all sorted out)

--Ozark