script sitter qui utilise toutes les animations, de façon aléatoire en changeant toutes les 60 sec

Répondre
Partager Rechercher
Bonjour,
je suis en train de créer un socle pour poser mon avartar quand je mixe

https://gyazo.com/2673d32b1f437ddfbd334f3b17bf0347

en en gros j'ai plusieures animations
et j'aimerais bien que le script puisse les utiliser toutes
de façon aleatoire et qu'il les change toutes les 60 secondes (par exemple)


string animation; // the first animation in inventory will automatically be used
// the animation name must be stored globally to be able to stop the animation when standing up

default
{
state_entry()
{
// set sit target, otherwise this will not work
llSitTarget(<0.4, 0.0, 1.0>, ZERO_ROTATION);//Edit to change start location of animation.
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
key av = llAvatarOnSitTarget();
if (av) //evaluated as true if not NULL_KEY or invalid
llRequestPermissions(av, PERMISSION_TRIGGER_ANIMATION);
else // avatar is standing up
{
if (animation)
llStopAnimation(animation); // stop the started animation
llResetScript(); // release the avatar animation permissions
}
}
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
animation = llGetInventoryName(INVENTORY_ANIMATION,0); // get the first animation from inventory
if (animation)
{
llStopAnimation("sit"); // stop the default sit animation
llStartAnimation(animation);
}
}
}
}

alors pourquoi un socle? parce que comme ça peu importe où je mixe, je peux être toujours réglée à la bonne hauteur et utiliser les animations que je préfére
tout en ayant quelque chose qui s'auto gère pendant que je mixe (d'où le besoin de random)

je suis pratiquement certaine que c'est possible et je sais que c'est dans animation = llGetInventoryName(INVENTORY_ANIMATION,0);
mais je sais pas faire

résolut

Dernière modification par *RAV3N* ; 21/09/2020 à 12h13. Motif: résolut
Hellow, j' avais déjà fait un truc equivalent il y a quelques temps, j' ai donc rajouté la fonction "random"....il suffit de mettre ce script dans une prim, ajouter les anims souhaitées et s' assoir dessus, le clic déclenche un menu, tu peux jouer l' anim que tu veux ou mettre en random....le menu s' adapte tout seul si tu ajoutes ou enlèves des anims....le mieux est de rendre le prim transparent, pour règler finement la distance des pieds au sol en fonction des anims....







integer canal;
integer ecoute;
integer count = 1;
integer index;
integer num;

float chgt_anim = 60.0;

key avat;
key owner;

vector pos = <0.0,0.0,0.7>;

list ANIM_MENU;
list REF_MENU;
list ALEAT;

list order_buttons(list buttons)
{
return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4)
+ llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);
}

Stop_All_Animations(key avatar)
{
list animations = llGetAnimationList(avatar);
integer i;

for(i = 0; i < llGetListLength(animations); ++i)
{
llStopAnimation(llList2Key(animations, i));
}
}

PresentMenu()
{
num = llGetInventoryNumber(INVENTORY_ANIMATION);

if(num <= 11)
{
ANIM_MENU = ["RANDOM"];
REF_MENU = ["RANDOM"];

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 = ["<<<<<", ">>>>>","RANDOM"];
REF_MENU = ["<<<<<", ">>>>>","RANDOM"];

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 - 9, x - 1);
}
REF_MENU += name;
}
}
}

llSetTimerEvent(60.0);

ecoute = llListen(canal, "", owner, "");

llDialog(owner, "Choisissez une pose", order_buttons(REF_MENU), canal);
}

default
{
on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
llSitTarget(pos, ZERO_ROTATION);
llSetTimerEvent(0.0);
owner = llGetOwner();
canal = (integer)("0xA" + llGetSubString((string)owner, 0,6 ));

key av = llAvatarOnSitTarget();
if(av == owner)
{
llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION, 0));
PresentMenu();
}
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
if(llAvatarOnSitTarget() != NULL_KEY)
{
avat = llAvatarOnSitTarget();

llRequestPermissions(owner, PERMISSION_TRIGGER_ANIMATION);
}

else
{
Stop_All_Animations(avat);
}
}

if(change & CHANGED_INVENTORY)
{
llResetScript();
}

if(change & CHANGED_OWNER)
{
llResetScript();
}
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
Stop_All_Animations(avat);

string animation = llGetInventoryName(INVENTORY_ANIMATION, 0);
llStartAnimation(animation);
}
}

touch_start(integer x)
{
if(llDetectedKey(0) == owner)
{
PresentMenu();
}
}

listen(integer ch, string name, key id, string msg)
{
llListenRemove(ecoute);
llSetTimerEvent(0.0);
if(msg == ">>>>>")
{
float MAX = llGetInventoryNumber(INVENTORY_ANIMATION);

MAX = MAX / 9.0;

integer MAXIMUM = llCeil(MAX);

++count;

if(count> MAXIMUM)
{
count = 1;
}

PresentMenu();
}

else if(msg == "<<<<<")
{
if(count > 1)
{
--count;
}

else
{
float MAX = llGetInventoryNumber(INVENTORY_ANIMATION);

MAX = MAX / 10.0;

integer MAXIMUM = llCeil(MAX);

count = MAXIMUM;
}

PresentMenu();
}

else if(msg == "RANDOM")
{
llSetTimerEvent(0.0);
state random;
}

else if(PERMISSION_TRIGGER_ANIMATION && id == owner)

{
Stop_All_Animations(id);

integer nb = llListFindList(REF_MENU, [msg]);

msg = llList2String(ANIM_MENU, nb);

llStartAnimation(msg);
PresentMenu();
}

else
{
if(llAvatarOnSitTarget() != NULL_KEY)
{
llRequestPermissions(owner, PERMISSION_TRIGGER_ANIMATION);
}
}
}

timer()
{
llListenRemove(ecoute);
llSetTimerEvent(0.0);
}
}


state random
{
state_entry()
{
ALEAT = [];

integer i;
for(i = 0; i < num; ++i)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);

if(name != "")
{
ALEAT += name;
}
}
llSetTimerEvent(0.1);
}

touch_end(integer x)
{
Stop_All_Animations(owner);
state default;
}

timer()
{
llSetTimerEvent(0.0);

index = (integer)llFrand((float)num);

Stop_All_Animations(owner);

string danse = llList2String(ALEAT, index);

llStartAnimation(danse);

llSetTimerEvent(chgt_anim);
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
Stop_All_Animations(avat);
llResetScript();
}

if(change & CHANGED_INVENTORY)
{
llResetScript();
}

if(change & CHANGED_OWNER)
{
llResetScript();
}
}
}
Répondre

Connectés sur ce fil

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