Jump to content

Numbered buttons in Dialog Menu for Animation HUD


AdminGirl
 Share

You are about to reply to a thread that has been inactive for 1510 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi

I found a really great full perm freebie animation/pose HUD script on the mp by Vlad Blackburn. Since most pose names are longer than 12 characters, I'm trying to make it so that the buttons can be numbers and the name of the poses appear as a list above the buttons. I've been working off a script example provided in the below thread.

https://community.secondlife.com/forums/topic/38305-dialog-choices-from-numbered-buttons/

https://community.secondlife.com/forums/topic/432512-recipe-dialog-menu/

 

I'm having a lot of trouble but I know my approach is way off - I've just been trying to copy & paste bits from one script into another.

Can anyone help point me in the right direction or is this too much for a noob and I should just go into the Wanted section? 😔

Here's the original animation HUD script:

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

 

Link to comment
Share on other sites

try contacting Vlad Blackburn and see if he will help you out

I have had contact with Vlad in the past with some of his products. Vlad said when I did, that he just makes stuff because he enjoys it and pitches his pricing at the levels he does just to help with his upload costs and get some little spending L$

if you ask Vlad he might help you out if you buy some of his stuff. Dunno for sure, but he might

  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...


If you want to implement it on your own you could try this:
(IMHO you only learn if you do so. However if you only copy&paste stuff from one script to another this "won't end well" 🙃 and you're better of asking the original author if he's willing to adjust it for you.)

To do so you can adjust the approach of the dialogs pagination in the Menu() function. You put the index of the animation name (in the animation_names list) on the button and add a line with this index + animation name to the text field of the dialog. (+1 to make it more "human readable")

e.g. Instead of using llListInsertList(...) you can use a loop to generate the button and text field strings and concatenate them into the variables.

// global
list animation_names = [(...)];

Menu()
{
	list buttons = ["<<", ">>", "Stop"];
	string text = "Choose Animation:\n";
	(...)
	for(i = start; i <= end; i++) {
		string anim = llList2String(animation_names, i);
		buttons += [(string)(i+1)];
		text    +=  (string)(i+1) + ": " + anim + "\n";
	}
	llDialog(..., text, buttons, ...);
}
                           

Where start and end are the first and last index to be displayed on the current page. (I haven't checked the original code if the variables there really satisfy these requirements.)

You also have to keep in mind, that the dialog now returns a number to listen(...). You can use this number (-1 see above) as an index in your animation list.

e.g.:

if((integer)msg > 0) {
    integer index = (integer)msg - 1;
    string anim = llList2String(animation_names, index);
    (...)
}

HTH
 

  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1510 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...