Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Problem with llDialog and listen when multiple avitars use object simultaniously.

OwenJ Juran
Registered User
Join date: 10 Jul 2007
Posts: 2
12-08-2007 19:37
I have written a dance pole script that allows multiple avitars to be animated at the same time. It works fine when one avitar is using the dance pole. But I have some problems that seem to be with the listen event when a second person is being animated.

When the pole is touched, the user is presented with a menu via llDialog. The Agent Key belonging to the avitar who touched the pole is passed correctly to llDialog. When the Listen event occurs, I seem to be getting the wrong Agent key passed. This results in the wrong avitar being affected by the llDialog command.

Help!!!

Thanks in Advance
OwenJ

Code Sample follows.

///////////// GLOBAL VARIABLES ///////////////
list ANIMATIONS;
list AGENTS;
list LISTENHANDLES;
list PERMISSIONS;


integer gAnimNumber;
integer gTotalAnims;
string gAnimName = "type";
integer permissionResult = FALSE;
integer debugMode = TRUE;
integer chatChannel = -10;
/////////// END GLOBAL VARIABLES /////////////

touch_start(integer num_detected) {
integer touchedIndex;

for (touchedIndex = 0; touchedIndex < num_detected; touchedIndex++) {
key agent = llDetectedKey(touchedIndex);

if (agent != NULL_KEY) {
integer agentIndex = llListFindList(AGENTS, (list) agent);
integer permissionsResult = FALSE;
if (agentIndex != -1) {
permissionsResult = llList2Integer(PERMISSIONS, agentIndex);

}

if ( agentIndex == -1 || permissionsResult == FALSE) {

AGENTS += [ agent ];
PERMISSIONS += [ FALSE ];
LISTENHANDLES += [ 0 ];
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION);
}

else {
llDialog(agent, "Dance Options", ANIMATIONS, chatChannel);
}
}
}
}

listen( integer channel, string name, key agent, string message ) {

integer agentIndex = llListFindList(AGENTS, (list) agent);
integer listenHandle = llList2Integer(LISTENHANDLES, agentIndex);

if (agentIndex != -1) {

if (message == "Stop";) {

llRequestPermissions(agent, FALSE);

if (gAnimName != "";)
llStopAnimation(gAnimName);

llListenRemove(listenHandle);
AGENTS = llDeleteSubList(AGENTS, agentIndex, agentIndex);
PERMISSIONS = llDeleteSubList(PERMISSIONS, agentIndex, agentIndex);
LISTENHANDLES = llDeleteSubList(LISTENHANDLES, agentIndex, agentIndex);


}
else {

if (~llListFindList(ANIMATIONS, (list) message)) {
if (gAnimName != "";)
llStopAnimation(gAnimName);

llStartAnimation( message );
if (debugMode == TRUE)
llOwnerSay("Animation: " + message);

gAnimName = message;
}
}
}
}
Papalopulus Kobolowski
working mind
Join date: 11 Aug 2006
Posts: 326
12-08-2007 20:46
hi, firts at least put a part of your code, with the part of the dialog and the listen event , and we can see it an post a reference or maybe a solution
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-08-2007 23:42
at a glance the code is ok, the problem is that you can only store permissions for one agent at a time per script, in fact if you request permissions again you lose the old ones even on the same av
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
OwenJ Juran
Registered User
Join date: 10 Jul 2007
Posts: 2
12-09-2007 02:54
Thankyou Void, you have been a great help.

I have modified the script so that permissions are checked every time the pole is touched. The llDialog function is now only called within the run_time_permissions callback event. This looks like it has fixed the problem. I am doing further testing.

I now understand where I went wrong. It is who the current permissions belong to that controls which avitar is the focus for the animation scripting functions. As such, whenever an avitar touches the pole to change its current animation, the permission settings have to be reset to that avitar before any animation functions can be called.