SL - Forum scripts

ajout d une fonction "sequence" dans un script de danse avec menu dans un objet

Répondre
Partager Rechercher
bonjour
voila un script de danse dans un objet mais il faut cliquer pour changer de pose serait t il possible d ajouter l option sequence dans le script pour avoir le choix j avoue secher a ce niveau la

integer CHANNEL; //channel for script to communicate on (generated radomly below)

vector Angle = <0,0,0>;
string LoadText = "Ready";
string Context = "Dance";

integer LISTENER; //listener placeholder to kill active listens

key AVATAR; //this will be set to the person sitting on the prim

vector POS = <0.0,-0,0.7>;//This is the initial sit target point.

list ANIM_MENU;
list REF_MENU;
integer COUNT = 1;
//---- Global variables are in all caps, local variables are all lowercase, do not try to use local variables out of context. ----//

Stop_All_Animations(key avatar) //this will be called below to stop the animations playing on an avatar, before animating them with your animations.
{
list animations = llGetAnimationList(avatar);//Make a list of all the animations they are currently playing
integer i;
for(i = 0; i < llGetListLength(animations); ++i)//Set up a loop
{
llStopAnimation(llList2Key(animations, i));//Stop all the animations
}
}

PresentMenu()
{
integer num = llGetInventoryNumber(INVENTORY_ANIMATION);
if(num <= 11)
{
ANIM_MENU = ["Move Av"];
REF_MENU = ["Move Av"];
integer i;
for(i = 0; i < num; ++i)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
if(name != "")
{
ANIM_MENU += name;
integer x = llStringLength(name);
if(x > 12)
{
name = llGetSubString(name, x - 10, x - 1);
}
REF_MENU += name;
}
}
}
else
{
ANIM_MENU = ["Previous", "Move Av", "Next"];
REF_MENU = ["Previous", "Move Av", "Next"];
integer start = (COUNT * 9) - 9;
integer stop = (COUNT * 9) - 1;
integer i;
for(i = start; i <= stop; ++i)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
if(name != "")
{
ANIM_MENU += name;
integer x = llStringLength(name);
if(x > 12)
{
name = llGetSubString(name, x - 10, x - 1);
}
REF_MENU += name;
}
}
}
//llSetTimerEvent(600); //Set up a timer to kill the listen if no response is received
CHANNEL = (integer)llFrand((2147283648) + 100000) * -1; //pick a random negative channel to communicate on
LISTENER = llListen(CHANNEL, "", llDetectedKey(0), "");//open a listen
llDialog(llAvatarOnSitTarget(), "Please choose an option", REF_MENU, CHANNEL);
}


default
{

state_entry()//State entry occurs whenever a script is reset, or when you make changes and save it.
{
llSitTarget(POS, ZERO_ROTATION);//set the point where the person will sit.
// llListen(-20140508,"",llGetOwner(),"");
llListen(-20140508,"","","");
}
changed(integer change)//if something changed
{
if(change & CHANGED_LINK)//if the something was a link change (when an avatar sits on an object, they link to it)
{
if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
{

AVATAR = llAvatarOnSitTarget();//Set the global variable to their key for use elsewhere.
// llSay(0," nouveau avatar assis");
llRequestPermissions(AVATAR, PERMISSION_TRIGGER_ANIMATION);
}

}
}

run_time_permissions(integer perm)//if we have permission to do something
{
if (perm & PERMISSION_TRIGGER_ANIMATION)//and that permisson is to animate them
{
Stop_All_Animations(AVATAR);//call the stop all aniamtions function.
string animation = llGetInventoryName(INVENTORY_ANIMATION, 0);//find the first animation in my inventory
llStartAnimation(animation);//animate them with it.
// llSay (0," l avatar utilise l animation"+ (string)animation );
llSay(-20140508,(string)animation );
}
}

touch_start(integer x)//when someone touches the object containing this script.
{
if(llDetectedKey(0) == llAvatarOnSitTarget()) //if the persosn touching this is sitting on the object
{
PresentMenu();
}
}

timer()// If they ran out of time before making a selection.
{
//llListenRemove(LISTENER); //remove the listener
llSetTimerEvent(0); //set listen remove timer back to off
}


listen(integer ch, string name, key id, string msg)//When a response is received
{
// llListenRemove(LISTENER); //remove the listener
// llSetTimerEvent(0); //set listen remove timer back to off
if(PERMISSION_TRIGGER_ANIMATION && ch == -20140508 && llAvatarOnSitTarget() != NULL_KEY)
{
//llSay(0,"demande d animation "+(string)msg);
//llStopAnimation(llList2Key(animations, i));
Stop_All_Animations(AVATAR);
llStartAnimation(msg);
}


else if(msg == "Move Av")
{
llSetTimerEvent(600); //Set up a timer to kill the listen if no response is received
LISTENER = llListen(9, "", id, "");//open a listen
llInstantMessage(id, "Please type the amount to move in this format Front/Back, Left/Right, Up/Down on channel 9. For example to move your avatar down 0.25m type /9 0,0,-0.25");
return;
}
else if(msg == "Next")
{
float MAX = llGetInventoryNumber(INVENTORY_ANIMATION);
MAX = MAX / 9.0;
integer MAXIMUM = llCeil(MAX);
++COUNT;
if(COUNT > MAXIMUM)
{
COUNT = 1;
}
PresentMenu();
}
else if(msg == "Previous")
{
if(COUNT > 1)
{
--COUNT;
}
else
{
float MAX = llGetInventoryNumber(INVENTORY_TEXTURE);
MAX = MAX / 10.0;
integer MAXIMUM = llCeil(MAX);
COUNT = MAXIMUM;
}
PresentMenu();
}
else if(ch == 9)
{
msg = "<"+msg+">";
POS += (vector)msg;
llSetLinkPrimitiveParams(2, [PRIM_POSITION, POS]);
return;
}


else if(PERMISSION_TRIGGER_ANIMATION && id == llAvatarOnSitTarget())//if we have permisson is to animate them, and they are still sitting on this.
{
Stop_All_Animations(id);
integer pos = llListFindList(REF_MENU, [msg]);
msg = llList2String(ANIM_MENU, pos);
llSay(-20140508,(string)msg);
//llSay(0,"utilise l animation du menu"+(string)msg);
llStartAnimation(msg);
}
else//if we don't have permission to animate them
{
if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
{
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);//request permission to animate them
}
}
}
}
// END //

Dernière modification par stefsparta ; 01/11/2019 à 17h18.
bon, petit truc vite fait qui devrait marcher....mais pour bien faire, faudrait tout reprendre, parce que le script de départ est....et là, ya du taf....j 'ai juste enlevé quelques trucs inutiles, voire fantaisistes....


integer CHANNEL; //channel for script to communicate on (generated radomly below)

integer LISTENER;
integer LISTENER2;
integer nb_danses;
integer aleat;

float tps_sequence = 30.0;//regler ici le temps entre deux changements de danses en mode sequence

key AVATAR; //this will be set to the person sitting on the prim

vector POS = <0.0,0.0,0.7>;//This is the initial sit target point.

list ANIM_MENU;
list REF_MENU;
integer COUNT = 1;

Stop_All_Animations(key avatar) //this will be called below to stop the animations playing on an avatar, before animating them with your animations.
{
list animations = llGetAnimationList(avatar);//Make a list of all the animations they are currently playing
integer i;
for(i = 0; i < llGetListLength(animations); ++i)//Set up a loop
{
llStopAnimation(llList2Key(animations, i));//Stop all the animations
}
}

PresentMenu()
{
nb_danses = llGetInventoryNumber(INVENTORY_ANIMATION);
if(nb_danses <= 11)
{
ANIM_MENU = ["Move Av","Sequence"];
REF_MENU = ["Move Av","Sequence"];
integer i;
for(i = 0; i < nb_danses; ++i)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
if(name != "")
{
ANIM_MENU += name;
integer x = llStringLength(name);
if(x > 12)
{
name = llGetSubString(name, x - 10, x - 1);
}
REF_MENU += name;
}
}
}
else
{
ANIM_MENU = ["Previous", "Move Av", "Next","Sequence"];
REF_MENU = ["Previous", "Move Av", "Next","Sequence"];
integer start = (COUNT * 8) - 8;
integer stop = (COUNT * 8) - 1;
integer i;
for(i = start; i <= stop; ++i)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
if(name != "")
{
ANIM_MENU += name;
integer x = llStringLength(name);
if(x > 12)
{
name = llGetSubString(name, x - 10, x - 1);
}
REF_MENU += name;
}
}
}
llSetTimerEvent(60.0); //Set up a timer to kill the listen if no response is received
//CHANNEL = (integer)llFrand((2147283648) + 100000) * -1; //pick a random negative channel to communicate on
//LISTENER = llListen(CHANNEL, "", AVATAR, "");//open a listen
llDialog(AVATAR, "Please choose an option", REF_MENU, CHANNEL);
}


default
{

state_entry()
{
llSitTarget(POS, ZERO_ROTATION);
CHANNEL = (integer)llFrand((2147283648) + 100000) * -1;
LISTENER = llListen(CHANNEL, "", AVATAR, "");//open a listen
}

changed(integer change)
{
if(change & CHANGED_LINK)//if the something was a link change (when an avatar sits on an object, they link to it)
{
if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
{

AVATAR = llAvatarOnSitTarget();//Set the global variable to their key for use elsewhere.
// llSay(0," nouveau avatar assis");
llRequestPermissions(AVATAR, PERMISSION_TRIGGER_ANIMATION);
}
else
{
llListenRemove(LISTENER); //remove the listener
llSetTimerEvent(0.0); //set listen remove timer back to off
}
}
}

run_time_permissions(integer perm)//if we have permission to do something
{
if (perm & PERMISSION_TRIGGER_ANIMATION)//and that permisson is to animate them
{
Stop_All_Animations(AVATAR);//call the stop all aniamtions function.
string animation = llGetInventoryName(INVENTORY_ANIMATION, 0);//find the first animation in my inventory
llStartAnimation(animation);//animate them with it.
// llSay (0," l avatar utilise l animation"+ (string)animation );
//llSay(-20140508,(string)animation );
}
}

touch_start(integer x)
{
if(llDetectedKey(0) == AVATAR) //if the persosn touching this is sitting on the object
{
PresentMenu();
}
}

timer()// If they ran out of time before making a selection.
{
llListenRemove(LISTENER); //remove the listener
llSetTimerEvent(0.0); //set listen remove timer back to off
}


listen(integer ch, string name, key id, string msg)
{
// llListenRemove(LISTENER); //remove the listener
// llSetTimerEvent(0); //set listen remove timer back to off
if(PERMISSION_TRIGGER_ANIMATION && ch == -20140508 && llAvatarOnSitTarget() != NULL_KEY)
{
//llSay(0,"demande d animation "+(string)msg);
//llStopAnimation(llList2Key(animations, i));
Stop_All_Animations(AVATAR);
llStartAnimation(msg);
}


else if(msg == "Move Av")
{
//llSetTimerEvent(60.0); //Set up a timer to kill the listen if no response is received
LISTENER2 = llListen(9, "", AVATAR, "");//open a listen
llInstantMessage(AVATAR, "Please type the amount to move in this format Front/Back, Left/Right, Up/Down on channel 9. For example to move your avatar down 0.25m type /9 0,0,-0.25");
return;
}
else if(msg == "Next")
{
float MAX = llGetInventoryNumber(INVENTORY_ANIMATION);
MAX = MAX / 9.0;
integer MAXIMUM = llCeil(MAX);
++COUNT;
if(COUNT > MAXIMUM)
{
COUNT = 1;
}
PresentMenu();
}
else if(msg == "Previous")
{
if(COUNT > 1)
{
--COUNT;
}
else
{
float MAX = llGetInventoryNumber(INVENTORY_ANIMATION);
MAX = MAX / 10.0;
integer MAXIMUM = llCeil(MAX);
COUNT = MAXIMUM;
}
PresentMenu();
}
else if(ch == 9)
{
msg = "<"+msg+">";
POS += (vector)msg;
llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, POS]);
llListenRemove(LISTENER2);
return;
}

else if(msg == "Sequence")
{
state sequence;
}


else if(PERMISSION_TRIGGER_ANIMATION && id == llAvatarOnSitTarget())//if we have permisson is to animate them, and they are still sitting on this.
{
Stop_All_Animations(id);
integer pos = llListFindList(REF_MENU, [msg]);
msg = llList2String(ANIM_MENU, pos);
//llSay(-20140508,(string)msg);
//llSay(0,"utilise l animation du menu"+(string)msg);
llStartAnimation(msg);
}
else//if we don't have permission to animate them
{
if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
{
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);//request permission to animate them
}
}
}
}


state sequence
{
state_entry()
{
llSetTimerEvent(0.1);
LISTENER = llListen(CHANNEL, "", AVATAR, "");//open a listen
}
changed(integer change)
{
if(change & CHANGED_LINK)
{
llListenRemove(LISTENER); //remove the listener
llSetTimerEvent(0.0); //set listen remove timer back to off
Stop_All_Animations(AVATAR);
}
}

timer()// If they ran out of time before making a selection.
{
nb_danses = llGetInventoryNumber(INVENTORY_ANIMATION);
aleat = (integer)llFrand(nb_danses);
string danse = llGetInventoryName(INVENTORY_ANIMATION, aleat);

Stop_All_Animations(AVATAR);
llStartAnimation(danse);
llSetTimerEvent(tps_sequence);
}

touch_start(integer x)
{
llSetTimerEvent(0.0);
if(llDetectedKey(0) == AVATAR) //if the persosn touching this is sitting on the object
{
PresentMenu();
//Stop_All_Animations(AVATAR);
state default;
}
}

listen(integer ch, string name, key id, string msg)
{
llSetTimerEvent(0.0);
state default;
}
}
ajout d une fonction "sequence" dans un script de danse avec menu dans un objet
bonjour merci encoe une fois cela fonctionne mais, et ou il y a un mais mdr quand on se leve le script ne fonctionne plus impossible de changer de danse ou d activer la séquence je suis obligé de réinitialiser le script
Citation :
Publié par MenthalOH
bon, petit truc vite fait qui devrait marcher....mais pour bien faire, faudrait tout reprendre, parce que le script de départ est....et là, ya du taf....j 'ai juste enlevé quelques trucs inutiles, voire fantaisistes....


integer CHANNEL; //channel for script to communicate on (generated radomly below)

integer LISTENER;
integer LISTENER2;
integer nb_danses;
integer aleat;

float tps_sequence = 30.0;//regler ici le temps entre deux changements de danses en mode sequence

key AVATAR; //this will be set to the person sitting on the prim

vector POS = <0.0,0.0,0.7>;//This is the initial sit target point.

list ANIM_MENU;
list REF_MENU;
integer COUNT = 1;

Stop_All_Animations(key avatar) //this will be called below to stop the animations playing on an avatar, before animating them with your animations.
{
list animations = llGetAnimationList(avatar);//Make a list of all the animations they are currently playing
integer i;
for(i = 0; i < llGetListLength(animations); ++i)//Set up a loop
{
llStopAnimation(llList2Key(animations, i));//Stop all the animations
}
}

PresentMenu()
{
nb_danses = llGetInventoryNumber(INVENTORY_ANIMATION);
if(nb_danses <= 11)
{
ANIM_MENU = ["Move Av","Sequence"];
REF_MENU = ["Move Av","Sequence"];
integer i;
for(i = 0; i < nb_danses; ++i)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
if(name != "")
{
ANIM_MENU += name;
integer x = llStringLength(name);
if(x > 12)
{
name = llGetSubString(name, x - 10, x - 1);
}
REF_MENU += name;
}
}
}
else
{
ANIM_MENU = ["Previous", "Move Av", "Next","Sequence"];
REF_MENU = ["Previous", "Move Av", "Next","Sequence"];
integer start = (COUNT * 8) - 8;
integer stop = (COUNT * 8) - 1;
integer i;
for(i = start; i <= stop; ++i)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
if(name != "")
{
ANIM_MENU += name;
integer x = llStringLength(name);
if(x > 12)
{
name = llGetSubString(name, x - 10, x - 1);
}
REF_MENU += name;
}
}
}
llSetTimerEvent(60.0); //Set up a timer to kill the listen if no response is received
//CHANNEL = (integer)llFrand((2147283648) + 100000) * -1; //pick a random negative channel to communicate on
//LISTENER = llListen(CHANNEL, "", AVATAR, "");//open a listen
llDialog(AVATAR, "Please choose an option", REF_MENU, CHANNEL);
}


default
{

state_entry()
{
llSitTarget(POS, ZERO_ROTATION);
CHANNEL = (integer)llFrand((2147283648) + 100000) * -1;
LISTENER = llListen(CHANNEL, "", AVATAR, "");//open a listen
}

changed(integer change)
{
if(change & CHANGED_LINK)//if the something was a link change (when an avatar sits on an object, they link to it)
{
if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
{

AVATAR = llAvatarOnSitTarget();//Set the global variable to their key for use elsewhere.
// llSay(0," nouveau avatar assis");
llRequestPermissions(AVATAR, PERMISSION_TRIGGER_ANIMATION);
}
else
{
llListenRemove(LISTENER); //remove the listener
llSetTimerEvent(0.0); //set listen remove timer back to off
}
}
}

run_time_permissions(integer perm)//if we have permission to do something
{
if (perm & PERMISSION_TRIGGER_ANIMATION)//and that permisson is to animate them
{
Stop_All_Animations(AVATAR);//call the stop all aniamtions function.
string animation = llGetInventoryName(INVENTORY_ANIMATION, 0);//find the first animation in my inventory
llStartAnimation(animation);//animate them with it.
// llSay (0," l avatar utilise l animation"+ (string)animation );
//llSay(-20140508,(string)animation );
}
}

touch_start(integer x)
{
if(llDetectedKey(0) == AVATAR) //if the persosn touching this is sitting on the object
{
PresentMenu();
}
}

timer()// If they ran out of time before making a selection.
{
llListenRemove(LISTENER); //remove the listener
llSetTimerEvent(0.0); //set listen remove timer back to off
}


listen(integer ch, string name, key id, string msg)
{
// llListenRemove(LISTENER); //remove the listener
// llSetTimerEvent(0); //set listen remove timer back to off
if(PERMISSION_TRIGGER_ANIMATION && ch == -20140508 && llAvatarOnSitTarget() != NULL_KEY)
{
//llSay(0,"demande d animation "+(string)msg);
//llStopAnimation(llList2Key(animations, i));
Stop_All_Animations(AVATAR);
llStartAnimation(msg);
}


else if(msg == "Move Av")
{
//llSetTimerEvent(60.0); //Set up a timer to kill the listen if no response is received
LISTENER2 = llListen(9, "", AVATAR, "");//open a listen
llInstantMessage(AVATAR, "Please type the amount to move in this format Front/Back, Left/Right, Up/Down on channel 9. For example to move your avatar down 0.25m type /9 0,0,-0.25");
return;
}
else if(msg == "Next")
{
float MAX = llGetInventoryNumber(INVENTORY_ANIMATION);
MAX = MAX / 9.0;
integer MAXIMUM = llCeil(MAX);
++COUNT;
if(COUNT > MAXIMUM)
{
COUNT = 1;
}
PresentMenu();
}
else if(msg == "Previous")
{
if(COUNT > 1)
{
--COUNT;
}
else
{
float MAX = llGetInventoryNumber(INVENTORY_ANIMATION);
MAX = MAX / 10.0;
integer MAXIMUM = llCeil(MAX);
COUNT = MAXIMUM;
}
PresentMenu();
}
else if(ch == 9)
{
msg = "<"+msg+">";
POS += (vector)msg;
llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, POS]);
llListenRemove(LISTENER2);
return;
}

else if(msg == "Sequence")
{
state sequence;
}


else if(PERMISSION_TRIGGER_ANIMATION && id == llAvatarOnSitTarget())//if we have permisson is to animate them, and they are still sitting on this.
{
Stop_All_Animations(id);
integer pos = llListFindList(REF_MENU, [msg]);
msg = llList2String(ANIM_MENU, pos);
//llSay(-20140508,(string)msg);
//llSay(0,"utilise l animation du menu"+(string)msg);
llStartAnimation(msg);
}
else//if we don't have permission to animate them
{
if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
{
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);//request permission to animate them
}
}
}
}


state sequence
{
state_entry()
{
llSetTimerEvent(0.1);
LISTENER = llListen(CHANNEL, "", AVATAR, "");//open a listen
}
changed(integer change)
{
if(change & CHANGED_LINK)
{
llListenRemove(LISTENER); //remove the listener
llSetTimerEvent(0.0); //set listen remove timer back to off
Stop_All_Animations(AVATAR);
}
}

timer()// If they ran out of time before making a selection.
{
nb_danses = llGetInventoryNumber(INVENTORY_ANIMATION);
aleat = (integer)llFrand(nb_danses);
string danse = llGetInventoryName(INVENTORY_ANIMATION, aleat);

Stop_All_Animations(AVATAR);
llStartAnimation(danse);
llSetTimerEvent(tps_sequence);
}

touch_start(integer x)
{
llSetTimerEvent(0.0);
if(llDetectedKey(0) == AVATAR) //if the persosn touching this is sitting on the object
{
PresentMenu();
//Stop_All_Animations(AVATAR);
state default;
}
}

listen(integer ch, string name, key id, string msg)
{
llSetTimerEvent(0.0);
state default;
}
}
euh....pas sur de comprendre le problème....c' est quoi l' interêt de changer de danse si on est plus sur la balle ? et pour avoir le menu, il faut être sur la balle...
ajout d une fonction "sequence" dans un script de danse avec menu dans un objet
j explique mieux le script ne marche q une fois et quand on se lève si l on se remet sur la balle le script ne marche plus il faut le réinitialiser.
Citation :
Publié par MenthalOH
euh....pas sur de comprendre le problème....c' est quoi l' interêt de changer de danse si on est plus sur la balle ? et pour avoir le menu, il faut être sur la balle...

Dernière modification par stefsparta ; 02/11/2019 à 13h58.
voili...


integer CHANNEL; //channel for script to communicate on (generated radomly below)

integer LISTENER;
integer LISTENER2;
integer nb_danses;
integer aleat;

float tps_sequence = 30.0;//regler ici le temps entre deux changements de danses en mode sequence

key AVATAR; //this will be set to the person sitting on the prim

vector POS = <0.0,0.0,0.7>;//This is the initial sit target point.

list ANIM_MENU;
list REF_MENU;
integer COUNT = 1;

Stop_All_Animations(key avatar) //this will be called below to stop the animations playing on an avatar, before animating them with your animations.
{
list animations = llGetAnimationList(avatar);//Make a list of all the animations they are currently playing
integer i;
for(i = 0; i < llGetListLength(animations); ++i)//Set up a loop
{
llStopAnimation(llList2Key(animations, i));//Stop all the animations
}
}

PresentMenu()
{
nb_danses = llGetInventoryNumber(INVENTORY_ANIMATION);
if(nb_danses <= 11)
{
ANIM_MENU = ["Move Av","Sequence"];
REF_MENU = ["Move Av","Sequence"];
integer i;
for(i = 0; i < nb_danses; ++i)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
if(name != "")
{
ANIM_MENU += name;
integer x = llStringLength(name);
if(x > 12)
{
name = llGetSubString(name, x - 10, x - 1);
}
REF_MENU += name;
}
}
}
else
{
ANIM_MENU = ["Previous", "Move Av", "Next","Sequence"];
REF_MENU = ["Previous", "Move Av", "Next","Sequence"];
integer start = (COUNT * 8) - 8;
integer stop = (COUNT * 8) - 1;
integer i;
for(i = start; i <= stop; ++i)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
if(name != "")
{
ANIM_MENU += name;
integer x = llStringLength(name);
if(x > 12)
{
name = llGetSubString(name, x - 10, x - 1);
}
REF_MENU += name;
}
}
}
llSetTimerEvent(60.0); //Set up a timer to kill the listen if no response is received
//CHANNEL = (integer)llFrand((2147283648) + 100000) * -1; //pick a random negative channel to communicate on
//LISTENER = llListen(CHANNEL, "", AVATAR, "");//open a listen
llDialog(AVATAR, "Please choose an option", REF_MENU, CHANNEL);
}


default
{

state_entry()
{
llSitTarget(POS, ZERO_ROTATION);
CHANNEL = (integer)llFrand((2147283648) + 100000) * -1;
LISTENER = llListen(CHANNEL, "", AVATAR, "");//open a listen
}

changed(integer change)
{
if(change & CHANGED_LINK)//if the something was a link change (when an avatar sits on an object, they link to it)
{
if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
{

AVATAR = llAvatarOnSitTarget();//Set the global variable to their key for use elsewhere.
// llSay(0," nouveau avatar assis");
llRequestPermissions(AVATAR, PERMISSION_TRIGGER_ANIMATION);
}
else
{
llResetScript();
}
}
}

run_time_permissions(integer perm)//if we have permission to do something
{
if (perm & PERMISSION_TRIGGER_ANIMATION)//and that permisson is to animate them
{
Stop_All_Animations(AVATAR);//call the stop all aniamtions function.
string animation = llGetInventoryName(INVENTORY_ANIMATION, 0);//find the first animation in my inventory
llStartAnimation(animation);//animate them with it.
// llSay (0," l avatar utilise l animation"+ (string)animation );
//llSay(-20140508,(string)animation );
}
}

touch_start(integer x)
{
if(llDetectedKey(0) == AVATAR) //if the persosn touching this is sitting on the object
{
PresentMenu();
}
}

timer()// If they ran out of time before making a selection.
{
llListenRemove(LISTENER); //remove the listener
llSetTimerEvent(0.0); //set listen remove timer back to off
}


listen(integer ch, string name, key id, string msg)
{
// llListenRemove(LISTENER); //remove the listener
// llSetTimerEvent(0); //set listen remove timer back to off
if(PERMISSION_TRIGGER_ANIMATION && ch == -20140508 && llAvatarOnSitTarget() != NULL_KEY)
{
//llSay(0,"demande d animation "+(string)msg);
//llStopAnimation(llList2Key(animations, i));
Stop_All_Animations(AVATAR);
llStartAnimation(msg);
}


else if(msg == "Move Av")
{
//llSetTimerEvent(60.0); //Set up a timer to kill the listen if no response is received
LISTENER2 = llListen(9, "", AVATAR, "");//open a listen
llInstantMessage(AVATAR, "Please type the amount to move in this format Front/Back, Left/Right, Up/Down on channel 9. For example to move your avatar down 0.25m type /9 0,0,-0.25");
return;
}
else if(msg == "Next")
{
float MAX = llGetInventoryNumber(INVENTORY_ANIMATION);
MAX = MAX / 9.0;
integer MAXIMUM = llCeil(MAX);
++COUNT;
if(COUNT > MAXIMUM)
{
COUNT = 1;
}
PresentMenu();
}
else if(msg == "Previous")
{
if(COUNT > 1)
{
--COUNT;
}
else
{
float MAX = llGetInventoryNumber(INVENTORY_ANIMATION);
MAX = MAX / 10.0;
integer MAXIMUM = llCeil(MAX);
COUNT = MAXIMUM;
}
PresentMenu();
}
else if(ch == 9)
{
msg = "<"+msg+">";
POS += (vector)msg;
llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, POS]);
llListenRemove(LISTENER2);
return;
}

else if(msg == "Sequence")
{
state sequence;
}


else if(PERMISSION_TRIGGER_ANIMATION && id == llAvatarOnSitTarget())//if we have permisson is to animate them, and they are still sitting on this.
{
Stop_All_Animations(id);
integer pos = llListFindList(REF_MENU, [msg]);
msg = llList2String(ANIM_MENU, pos);
//llSay(-20140508,(string)msg);
//llSay(0,"utilise l animation du menu"+(string)msg);
llStartAnimation(msg);
}
else//if we don't have permission to animate them
{
if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
{
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);//request permission to animate them
}
}
}
}


state sequence
{
state_entry()
{
llSetTimerEvent(0.1);
LISTENER = llListen(CHANNEL, "", AVATAR, "");//open a listen
}
changed(integer change)
{
if(change & CHANGED_LINK)
{
Stop_All_Animations(AVATAR);
llResetScript();
}
}

timer()// If they ran out of time before making a selection.
{
nb_danses = llGetInventoryNumber(INVENTORY_ANIMATION);
aleat = (integer)llFrand(nb_danses);
string danse = llGetInventoryName(INVENTORY_ANIMATION, aleat);

Stop_All_Animations(AVATAR);
llStartAnimation(danse);
llSetTimerEvent(tps_sequence);
}

touch_start(integer x)
{
llSetTimerEvent(0.0);
if(llDetectedKey(0) == AVATAR) //if the persosn touching this is sitting on the object
{
PresentMenu();
//Stop_All_Animations(AVATAR);
state default;
}
}

listen(integer ch, string name, key id, string msg)
{
llSetTimerEvent(0.0);
state default;
}
}
Répondre

Connectés sur ce fil

 
1 connecté (0 membre et 1 invité) Afficher la liste détaillée des connectés