12-02-2020, 10:51 PM
Code:
float timeout = 60.0;
key owner;
list animation_names;
list animation_buttons;
integer animations_count;
string animation;
integer listener;
integer page;
GetAnimations ()
{
animation_names = [];
animation_buttons = [];
animations_count = llGetInventoryNumber (INVENTORY_ANIMATION);
integer index = 0;
while (index < animations_count)
{
string name = llGetInventoryName (INVENTORY_ANIMATION, index++);
animation_buttons += llGetSubString (name, 0, 23);
animation_names += name;
}
}
Menu ()
{
if (animations_count)
{
string text = "\n" + llList2String (["Currently playing \"" + animation + "\"\n\n", "" ], animation == "") + "Select an animation:";
list buttons;
integer start = 0;
integer end = ~-animations_count;
if (animations_count > 9)
{
integer pages = end / 7;
if (page < 0) page = pages;
else if (page > pages) page = 0;
if (page == pages) start = animations_count - 7;
else end = (start = page * 7) + 6;
buttons = ["<<"] + llListInsertList (llList2List (animation_buttons, start, end), (list) ">>", 1);
text += "\n\n(" + (string) (-~start) + " to " + (string) (-~end) + " of " + (string) animations_count + ", page " + (string) (-~page) + " of " + (string) (-~pages) + ")";
}
else buttons = llList2List (animation_buttons, start, end);
llDialog (owner, text, ["END", llList2String (["STOP", " "], animation == ""), " "] + buttons, StartDialog ());
}
else llDialog (owner, "\nNo animations found.", ["END"], StartDialog ());
}
integer StartDialog ()
{
integer channel;
listener = llListen (channel = (integer) llFrand (-1999000001.0) - 1000000, "", owner, "");
llSetTimerEvent (timeout);
return channel;
}
EndDialog ()
{
llSetTimerEvent (0.0);
llListenRemove (listener);
}
StartAnimation (integer index)
{
StopAnimation ();
llStartAnimation (animation = llList2String (animation_names, index));
}
StopAnimation ()
{
if (animation)
{
llStopAnimation (animation);
animation = "";
}
}
default
{
state_entry ()
{
owner = llGetOwner ();
GetAnimations ();
if (llGetAttached ()) llRequestPermissions (owner, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
}
attach (key id)
{
if (id) llRequestPermissions (id, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
}
run_time_permissions (integer permissions)
{
if (!(permissions & PERMISSION_TRIGGER_ANIMATION))
{
llPlaySound ("d5567c52-b78d-f78f-bcb1-605701b3af24", 1.0);
llOwnerSay ("You must give permission for this " + llGetObjectName () + " to animate your avatar for it to work!");
llResetScript ();
}
if (permissions & PERMISSION_TAKE_CONTROLS) llTakeControls (CONTROL_ML_LBUTTON, FALSE, TRUE);
}
changed (integer change)
{
if (change & CHANGED_INVENTORY) GetAnimations ();
else if (change & CHANGED_OWNER) llResetScript ();
}
touch_end (integer count)
{
EndDialog ();
Menu ();
}
listen (integer channel, string name, key id, string message)
{
EndDialog ();
if (message != "END")
{
integer index;
if (~(index = llListFindList (animation_buttons, (list) message))) StartAnimation (index);
else if (message == "STOP") StopAnimation ();
else if (message == "<<") --page;
else if (message == ">>") ++page;
Menu ();
}
}
timer ()
{
EndDialog ();
llPlaySound ("d5567c52-b78d-f78f-bcb1-605701b3af24", 1.0);
llDialog (owner, "\n" + llGetObjectName () + " menu timeout.", ["END"], -1);
}
}
that script goes inside the box
inside the box you put your animations
attach box as hud
when you touch the box a menu with animations will open
you can customize the hud box as you like
has many genres the package
cheers