Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Chimera Script

Candace Sahara
Registered User
Join date: 8 May 2009
Posts: 11
06-21-2009 13:39
OK, this one seemed real simple... Take a ball, toss some dances in it, then have a master script keeping tabs on what avatar keys are dancing, sends out the next dance animation in the sequence, and has 20 or so scripts to gather run time permissions from detectedkeys that click the ball.

The way I wrote the scripts is:
Master script has a list of all animations in the object
When clicked, it sends the detected key via linked message to the first available dance slot
That script gathers run time permissions from the key and sends a signal back to the master script to say permissions have been granted and starts the first animation
The master listens for a stop command, matches the avatar key and sends a signla to the appropriate script to stop animating the avatar

Sounds simple enough... But for whatever reason I get I get errors playing subsequent animations and run time permissions seem a little off?

Any ideas???
Cerise Sorbet
Registered User
Join date: 8 Jun 2008
Posts: 254
06-21-2009 18:12
Hi Candace, there can be only guesses if you can't post a script. Can you make the scripts say all the things they do? It will be good to repeat the link messages to know they go to the right place at the right time.
Candace Sahara
Registered User
Join date: 8 May 2009
Posts: 11
Question with scripts
06-22-2009 04:05
Here are my main scripts. Hope this helps to get a fwew answers

// The Master Chimera Script...

key k;
list keys = ["NULL","NULL","NULL"];
list dances = ["f_dance_06","f_dance_08","f_dance_09","f_dance_27"];
integer currentdance = 0;
integer active = 0;
integer dancetime = 90;

default
{
state_entry()
{
llListen(33,"","","";);
llSetTimerEvent(0);
}

timer(){
if (active == 0){
llSetTimerEvent(0);
} else {
currentdance++;
if (currentdance >= llGetListLength(dances)) currentdance = 0;
string mes = "Next|"+llList2String(dances,currentdance);
llMessageLinked(LINK_SET,0,mes,NULL_KEY);
llOwnerSay("Active dancers = "+(string)active+" - Now playing dance, "+llList2String(dances,currentdance));
}
}

listen(integer channel, string name, key id, string message){
message = llToLower(message);
if (message == "stop";){
integer y = llListFindList(keys,[(string)id]);
if (y != -1){
string mes = "Stop|"+llList2String(keys,y);
keys = llListReplaceList(keys,["NULL"],y,y);
active --;
y++;
llMessageLinked(LINK_SET,y,mes,NULL_KEY);
}
}
}

link_message(integer source, integer num, string message, key id)
{
if (num == 99){
k = (key)message;
integer y = llListFindList(keys,[(string)k]);
if (y == -1){
integer z = llListFindList(keys,["NULL"]);
if (z != -1){
keys = llListReplaceList(keys,[(string)k],z,z);
active++;
if (active == 1) llSetTimerEvent(dancetime);
}
}
}
}

touch_start(integer total_number)
{
k = llDetectedKey(0);
integer y = llListFindList(keys,[(string)k]);
if (y == -1){
integer z = llListFindList(keys,["NULL"]);
if (z != -1){
z++;
string mes = "Start|"+(string)k+"|"+llList2String(dances,currentdance);
llMessageLinked(LINK_SET,z,mes,NULL_KEY);
} else {
llInstantMessage(k,"I'm sorry but all dance slots are in use on this chimera";);
}
} else {
llInstantMessage(k,"You are already dancing on this chimera";);
}
}
}

// Script 1 (for use with first permissions, 2 3 4 ... would be for others)

key k;
integer myNum;
string dance;

default
{
state_entry()
{
myNum = (integer)llGetScriptName();
}

link_message(integer source, integer num, string message, key id)
{
if (num == myNum || num == 0){
if (k != NULL_KEY){
list commands = llParseString2List(message,["|"],[]);
string myCom = llList2String(commands,0);
if (myCom =="Start";){
k = llList2Key(commands,1);
dance = llList2String(commands,2);
llRequestPermissions( k ,PERMISSION_TRIGGER_ANIMATION );
} else if (myCom == "Stop";){
llStopAnimation(dance);
k = NULL_KEY;
} else if (myCom == "Next";){
llStopAnimation(dance);
dance = llList2String(commands,1);
llStartAnimation(dance);
}
}
}
}

run_time_permissions(integer parm) {
if( parm == PERMISSION_TRIGGER_ANIMATION ) {
llStartAnimation(dance);
string mes = (string)k;
llMessageLinked(LINK_SET,99,mes,NULL_KEY);
}
}
}
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-22-2009 21:53
the sub script preserves the avs key unless an av clicks stop, and then it tries to animate that av on every next dance, even if they aren't present.... that's probably where the errors are coming from
_____________________
|
| . "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...
| -
Candace Sahara
Registered User
Join date: 8 May 2009
Posts: 11
Not quite sure that is the problem
06-23-2009 05:34
When the AV says /33stop the master script finds the key of who says they are stopping in the master list of keys. Based upon the which slot they are dancing in it sends a signal to that script to stop animating that AV.

I need to triple check that the right message is being sent to the right script...
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
06-23-2009 15:27
From: Candace Sahara
When the AV says /33stop the master script finds the key of who says they are stopping in the master list of keys. Based upon the which slot they are dancing in it sends a signal to that script to stop animating that AV


From: someone

else if (myCom == "Stop";){
llStopAnimation(dance);
k = NULL_KEY;
}


it looks like you're simply stopping the current animation, and then changing the key to null key, but you're not doing anything with the key afterwords, including trying to get, or in this case release permissions instead of changing the key, after you stop the dance, try resetting the script. (is there any way to release animation perms without resetting?)
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-23-2009 18:58
I think you misunderstood what I was trying to say...

situation:
av clicks chimera, is added, then leaves the sim WITHOUT sending a stop message. the permissions remain, but the av isn't there to be animated, and that's probably where the permissions warning is coming from...

From: Ruthven Willenov
(is there any way to release animation perms without resetting?)

yup... request new permissions... which could be the owner (and doesn't need to be the same type so you can use that to determine what to do), but I *THINK* that you can request on NULL_KEY with a valid permission type and that will clear them..

resetting the script would probably be optimal though.

oh and you don't actually have to set a variable for the av with permissions in a script, it's returned from llGetPermissionsKey
_____________________
|
| . "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...
| -
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
06-23-2009 20:17
aah i see what you mean, then the script should probably check if the avatar is in the sim before trying to start the anim, probably:

vector size = llGetAgentSize(k);

if(size == ZERO_VECTOR)//if it's zero vector, then they're not in the sim


or

if(llKey2Name(id) == "";)//if the name is empty, then they left, or you're checking with NULL_KEY
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369