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;
}
}
|