Jump to content

HUD script animation player


sndbad Ghost
 Share

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

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

Recommended Posts

LOL  .  I just told you how to start.  If you are totally new to LSL scripting, though, you should start by learning the basics, not by taking on a project that takes some mild skill.  Making a HUD is not a big deal, but until you have a feel for how communication channels work ( and how the basic structure and flow of logic in LSL behaves), you'll waste a lot of time and write garbage scripts.  Take a look at a few tutorials >>> http://wiki.secondlife.com/wiki/LSL_Tutorial  and practice.  You are welcome to come back here and post your work if you have specific questions or get stuck at a key point. That's how a lot of new scripters learn.  The LSL Scripting forum is not designed as a place to get people to write scripts for you, though.  If that's what you want, you really should post in InWorld Employment and hire a scripter.

  • Like 1
Link to comment
Share on other sites

ok i have this script now its work fine with next button i add back button but not work 

 

orginal script

//////////////////////////////////////////////////////////////////////////////////////////////////////  Dance HUD script by Dave Bellman //////  Script loosly based on:// //      Animation Stand (Stand Script)//      by Teddy Wishbringer// //      Thanks go to Argent Stonecutter for assistance in streamlining and bug squishing.    ////      This script is given away free of charge with full permissions.  //      This is the case with the redistribution of both free and pay for items. //      If you re-use this script, please distribute it with full permissions and keep this notice//      //  //  Updated to version 2 during August 2009 - Dave Bellman//  Updated to version 2.1 September 2009. Very occasional bug found//                         Bug:   The timing dialog occasionally fails to appear.//                         Cause: Using the same chat channel for the main and timing dialogs. //                         Fix:   Added separate chat channels, listeners and listen handles for each dialog.//// // updated to version 2.2 by Quintessa Naire November 5, 2009.                                  Bug: The timing function failed to work even occasionally.                                                                              Cause:  syntax error                                                Fix:  added in a space where needed//////updated to version 2.3 by Quintessa Naire November 7, 2009.                                  Bug: The timing function failed to work after relogging.                                                                               Cause:  not resetting.                                              Fix:  Added reset on rez.// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Variables//integer time_between_changes = 30;// value in secondsinteger verbose = TRUE;// Send owner status messages toggleinteger ON = TRUE; // Main On Off togglevector on_colour = <1,1,1>;// colour of button tint when on (white)vector off_colour = <1,0.4,0.4>;// colour of button tint when off (red)    integer animation_qty; // Number of animations availableinteger animation_current; // Inventory number of current animationstring  animation_name = "just started"; // Name of current animationkey avatar = NULL_KEY; // Key of the avatar who's wearing the HUDlist buttons_main = ["Messages", "Landmark", "Instructions", "Stop", "Timing"]; // List of the buttons for the main dialoglist buttons_time  = ["Never", "2 hours", "1 hour", "3 minutes", "2 minutes", "1 minute", "30 seconds", "20 seconds", "10 seconds"]; // List of the buttons for the timing dialoginteger main_dialog_chat_channel = -67854; // Chat channel used by the main dialoginteger timing_dialog_chat_channel = -67853; // Chat channel used by the timing dialogstring spacer = "                                                                                           ";//put dialog messages on the second lineinteger listen_handle_main; // We need to remove the listener when we have an owner changeinteger listen_handle_messages; // same for the messages chat channel////////////////////////////////////////////////////////////////////////////////////////////////////// Functions//  update(){    // work out how many animations we have now    animation_qty = llGetInventoryNumber(INVENTORY_ANIMATION);     if (animation_qty > 0)    {        if(verbose)         {            llOwnerSay("I have " + (string)animation_qty+" dances");            if(time_between_changes>3599)            {                integer time = time_between_changes/3600;                if(time==1) llOwnerSay("I'll change dance once an hour");                else llOwnerSay("I'll change dance every "+(string)time+" hours");                return;            }            if(time_between_changes>59)            {                integer time = time_between_changes/60;                if(time==1) llOwnerSay("I'll change dance once a minute");                else llOwnerSay("I'll change dance every "+(string)time+" minutes");                return;            }            if(time_between_changes==0)            {                llOwnerSay("I'll let you decide when to change dance");                return;            }            integer time = time_between_changes;            llOwnerSay("I'll change dance every "+(string)time+" seconds");        }                if(ON) llSetTimerEvent((float)time_between_changes);        animation_name = "just started";        animation_current = 0;        if(ON) set_anim(animation_current);    }    else llOwnerSay("I have no dances. Please put some dances in me.");}    // Set the next animation available as the active oneset_anim(integer inventory_number){    // Get the name of the animation is inventory position (inventory_number)    string new_animation_name = llGetInventoryName(INVENTORY_ANIMATION,inventory_number);        if (avatar != NULL_KEY)     {        if(animation_name!="just started")           llStopAnimation(animation_name); // Stop current animation        llStartAnimation(new_animation_name); // Start next animation    }    // Set the new animation name as the current    animation_name = new_animation_name; } turn_on(){    ON = TRUE;    if(animation_qty>0)    {        animation_name = "just started";        set_anim(animation_current);        llSetTimerEvent(time_between_changes);    }    else    {        llOwnerSay("I have no dances. Please put some dances in me.");    }    llSetColor(on_colour, ALL_SIDES);  }turn_off(){    ON = FALSE;     llStopAnimation(animation_name);    llSetTimerEvent(0);// save those mS!    llSetColor(off_colour, ALL_SIDES);  }////////////////////////////////////////////////////////////////////////////////////////////////////// Main body//   default{    state_entry()    {        // ask for permission to animate (only if HUD has been attached)         if(llGetAttached()>0)         {            avatar = llGetOwner();            llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);             listen_handle_main = llListen(main_dialog_chat_channel, "", llGetOwner(), "");             listen_handle_messages = llListen(timing_dialog_chat_channel, "", llGetOwner(), "");        }        if(ON) llSetColor(on_colour, ALL_SIDES);        else llSetColor(off_colour, ALL_SIDES);    }                on_rez(integer rez)    {        llResetScript();    }        attach(key id)    {        if(id==NULL_KEY)// i.e. is detaching        {            if(animation_name!="just started")               llStopAnimation(animation_name); // Stop current animation        }          else        {            // store wearer UUID, ask for permission to animate            avatar = id;            llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);          }            }             // If touched, detect touch location and do what's required    touch_start(integer num)    {        // Get the name of the prim touched        string prim_touched = llGetLinkName(llDetectedLinkNumber(0));            if ((prim_touched == "next")&&ON) // The next button was pressed        {            // If the HUD has no dances, we can't do much            if(animation_qty==0)             {                llOwnerSay("I can't change to the next dance, as I have no dances. Please put some dances in me.");                return;            }            else            {                animation_current++; // Increment the animation inventory pointer                if ((animation_current + 1) > animation_qty) // Have we reached the last animation in the object?                {                    animation_current = 0; // We have, so wrap around back to the first one                }                set_anim(animation_current);                llSetTimerEvent((float)time_between_changes);                if(verbose) llOwnerSay("The current dance is now "+animation_name);                return;           }        }        else if ((prim_touched == "menu")&&ON)// The main button was pressed        {            // Bring up the main menu            llDialog(avatar, spacer+spacer+"Animazoo Dance HUD configuration", buttons_main,  main_dialog_chat_channel);             return;        }        else        {            if(ON)            {                turn_off();                                  return;               }            else            {                turn_on();                return;            }                                        }    }          timer()    {        if(avatar)        {            // increment the animation count and set the new animation            animation_current++;            if ((animation_current + 1) > animation_qty) animation_current = 0;             set_anim(animation_current);        }    }                changed(integer change)    {        // if animations are added or taken from inventory we need to update        if (change & CHANGED_INVENTORY) update();                // if we have a new owner, release the listener and reset everything        if(change & CHANGED_OWNER)         {            llOwnerSay("Ah! a new owner - hello! Please wait a moment whilst I reset...");            llListenRemove(listen_handle_main);            llListenRemove(listen_handle_messages);            llResetScript();              }    }        run_time_permissions(integer perm)    {        // Permissions are automatic when the object wearer is the owner        if (perm & PERMISSION_TRIGGER_ANIMATION) update();    }        listen(integer channel, string name, key id, string message)    {        // Dialog commands        if(channel == main_dialog_chat_channel)        {                     // Toggle owner messages                   if(message=="Messages")            {                if(verbose)                {                    verbose = FALSE;                    llOwnerSay("I will stop sending you status messages");                }                else                 {                    verbose = TRUE;                    llOwnerSay("I will send you status messages from now on");                                    }                return;            }                        // Stop dancing (works the same as turning off)            if(message=="Stop")            {                turn_off();                                   return;                   }                        // Give the user a copy of the instructions notecard            if(message=="Instructions")            {                llGiveInventory(avatar, "Animazoo dance HUD instructions v2.0");                return;            }                        // Give the user a landmark to the main store            if(message=="Landmark")            {                llGiveInventory(avatar, "Animazoo Brighton, Brightown (221, 69, 30)");                if(verbose) llOwnerSay("Visit Animazoo for more dances!");                return;             }                        // Show dialog giving option to change how often the dance changes            if(message=="Timing")            {                llDialog(avatar, spacer+spacer+"How often do you want the dance to change?", buttons_time, timing_dialog_chat_channel);                return;            }                    }                  if(channel == timing_dialog_chat_channel)        {            // Dialog messages from timing dialog. Sets the time between dance changes            if(message=="Never")     time_between_changes = 0;            if(message=="2 hours")    time_between_changes = 7200;            if(message=="1 hour")     time_between_changes = 3600;                     if(message=="3 minutes")  time_between_changes = 180;            if(message=="2 minutes")  time_between_changes = 120;            if(message=="1 minute")   time_between_changes = 60;            if(message=="30 seconds") time_between_changes = 30;            if(message=="20 seconds") time_between_changes = 20;            if(message=="10 seconds") time_between_changes = 10;            llSetTimerEvent((float) time_between_changes);            if(verbose)             {                if(time_between_changes>3599)                {                    integer time = time_between_changes/3600;                    if(time==1) llOwnerSay("I'll now change dance once an hour");                    else llOwnerSay("I'll now change dance every "+(string)time+" hours");                    return;                }                if(time_between_changes>59)                {                    integer time = time_between_changes/60;                    if(time==1) llOwnerSay("I'll now change dance once a minute");                    else llOwnerSay("I'll now change dance every "+(string)time+" minutes");                    return;                }                if(time_between_changes==0)                {                    llOwnerSay("I'll let you decide when to change dance from now on");                    return;                }                integer time = time_between_changes;                llOwnerSay("I'll now change dance every "+(string)time+" seconds");                return;                           }        }              }}

new edit line 214

//////////////////////////////////////////////////////////////////////////////////////////////////////  Dance HUD script by Dave Bellman //////  Script loosly based on:// //      Animation Stand (Stand Script)//      by Teddy Wishbringer// //      Thanks go to Argent Stonecutter for assistance in streamlining and bug squishing.    ////      This script is given away free of charge with full permissions.  //      This is the case with the redistribution of both free and pay for items. //      If you re-use this script, please distribute it with full permissions and keep this notice//      //  //  Updated to version 2 during August 2009 - Dave Bellman//  Updated to version 2.1 September 2009. Very occasional bug found//                         Bug:   The timing dialog occasionally fails to appear.//                         Cause: Using the same chat channel for the main and timing dialogs. //                         Fix:   Added separate chat channels, listeners and listen handles for each dialog.//// // updated to version 2.2 by Quintessa Naire November 5, 2009.                                  Bug: The timing function failed to work even occasionally.                                                                              Cause:  syntax error                                                Fix:  added in a space where needed//////updated to version 2.3 by Quintessa Naire November 7, 2009.                                  Bug: The timing function failed to work after relogging.                                                                               Cause:  not resetting.                                              Fix:  Added reset on rez.// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Variables//integer time_between_changes = 30000;// value in secondsinteger verbose = TRUE;// Send owner status messages toggleinteger ON = TRUE; // Main On Off togglevector on_colour = <1,1,1>;// colour of button tint when on (white)vector off_colour = <1,0.4,0.4>;// colour of button tint when off (red)    integer animation_qty; // Number of animations availableinteger animation_current; // Inventory number of current animationstring  animation_name = "just started"; // Name of current animationkey avatar = NULL_KEY; // Key of the avatar who's wearing the HUDlist buttons_main = ["Messages", "Landmark", "Instructions", "Stop", "Timing"]; // List of the buttons for the main dialoglist buttons_time  = ["Never", "2 hours", "1 hour", "3 minutes", "2 minutes", "1 minute", "30 seconds", "20 seconds", "10 seconds"]; // List of the buttons for the timing dialoginteger main_dialog_chat_channel = -67854; // Chat channel used by the main dialoginteger timing_dialog_chat_channel = -67853; // Chat channel used by the timing dialogstring spacer = "                                                                                           ";//put dialog messages on the second lineinteger listen_handle_main; // We need to remove the listener when we have an owner changeinteger listen_handle_messages; // same for the messages chat channel////////////////////////////////////////////////////////////////////////////////////////////////////// Functions//  update(){    // work out how many animations we have now    animation_qty = llGetInventoryNumber(INVENTORY_ANIMATION);     if (animation_qty > 0)    {        if(verbose)         {            llOwnerSay("I have " + (string)animation_qty+" dances");            if(time_between_changes>3599)            {                integer time = time_between_changes/3600;                if(time==1) llOwnerSay("I'll change dance once an hour");                else llOwnerSay("I'll change dance every "+(string)time+" hours");                return;            }            if(time_between_changes>59)            {                integer time = time_between_changes/60;                if(time==1) llOwnerSay("I'll change dance once a minute");                else llOwnerSay("I'll change dance every "+(string)time+" minutes");                return;            }            if(time_between_changes==0)            {                llOwnerSay("I'll let you decide when to change dance");                return;            }            integer time = time_between_changes;            llOwnerSay("I'll change dance every "+(string)time+" seconds");        }                if(ON) llSetTimerEvent((float)time_between_changes);        animation_name = "just started";        animation_current = 0;        if(ON) set_anim(animation_current);    }    else llOwnerSay("I have no dances. Please put some dances in me.");}    // Set the next animation available as the active oneset_anim(integer inventory_number){    // Get the name of the animation is inventory position (inventory_number)    string new_animation_name = llGetInventoryName(INVENTORY_ANIMATION,inventory_number);        if (avatar != NULL_KEY)     {        if(animation_name!="just started")           llStopAnimation(animation_name); // Stop current animation        llStartAnimation(new_animation_name); // Start next animation    }    // Set the new animation name as the current    animation_name = new_animation_name; } turn_on(){    ON = TRUE;    if(animation_qty>0)    {        animation_name = "just started";        set_anim(animation_current);        llSetTimerEvent(time_between_changes);    }    else    {        llOwnerSay("I have no dances. Please put some dances in me.");    }    llSetColor(on_colour, ALL_SIDES);  }turn_off(){    ON = FALSE;     llStopAnimation(animation_name);    llSetTimerEvent(0);// save those mS!    llSetColor(off_colour, ALL_SIDES);  }////////////////////////////////////////////////////////////////////////////////////////////////////// Main body//   default{    state_entry()    {        // ask for permission to animate (only if HUD has been attached)         if(llGetAttached()>0)         {            avatar = llGetOwner();            llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);             listen_handle_main = llListen(main_dialog_chat_channel, "", llGetOwner(), "");             listen_handle_messages = llListen(timing_dialog_chat_channel, "", llGetOwner(), "");        }        if(ON) llSetColor(on_colour, ALL_SIDES);        else llSetColor(off_colour, ALL_SIDES);    }                on_rez(integer rez)    {        llResetScript();    }        attach(key id)    {        if(id==NULL_KEY)// i.e. is detaching        {            if(animation_name!="just started")               llStopAnimation(animation_name); // Stop current animation        }          else        {            // store wearer UUID, ask for permission to animate            avatar = id;            llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);          }            }             // If touched, detect touch location and do what's required    touch_start(integer num)    {        // Get the name of the prim touched        string prim_touched = llGetLinkName(llDetectedLinkNumber(0));            if ((prim_touched == "next")&&ON) // The next button was pressed        {            // If the HUD has no dances, we can't do much            if(animation_qty==0)             {                                llOwnerSay("I can't change to the next dance, as I have no dances. Please put some dances in me.");                return;            }            else            {                animation_current++; // Increment the animation inventory pointer                if ((animation_current + 1) > animation_qty) // Have we reached the last animation in the object?                {                    animation_current = 0; // We have, so wrap around back to the first one                }                set_anim(animation_current);                llSetTimerEvent((float)time_between_changes);                if(verbose) llOwnerSay("The current dance is now "+animation_name);                return;           }        }                if ((prim_touched == "back")&&ON) // The next button was pressed        {            // If the HUD has no dances, we can't do much            if(animation_qty == 0)             {                                llOwnerSay("I can't change to the next dance, as I have no dances. Please put some dances in me.");                return;            }            else            {                animation_current++; // Increment the animation inventory pointer                if ((animation_current - 1) > animation_qty) // Have we reached the last animation in the object?                {                    animation_current = 0; // We have, so wrap around back to the first one                }                set_anim(animation_current);                llSetTimerEvent((float)time_between_changes);                if(verbose) llOwnerSay("The current dance is now "+animation_name);                return;           }        }        else if ((prim_touched == "menu")&&ON)// The main button was pressed        {            // Bring up the main menu            llDialog(avatar, spacer+spacer+"Animazoo Dance HUD configuration", buttons_main,  main_dialog_chat_channel);             return;        }        else        {            if(ON)            {                turn_off();                                  return;               }            else            {                turn_on();                return;            }                                        }    }          timer()    {        if(avatar)        {            // increment the animation count and set the new animation            animation_current++;            if ((animation_current + 1) > animation_qty) animation_current = 0;             set_anim(animation_current);        }    }                changed(integer change)    {        // if animations are added or taken from inventory we need to update        if (change & CHANGED_INVENTORY) update();                // if we have a new owner, release the listener and reset everything        if(change & CHANGED_OWNER)         {            llOwnerSay("Ah! a new owner - hello! Please wait a moment whilst I reset...");            llListenRemove(listen_handle_main);            llListenRemove(listen_handle_messages);            llResetScript();              }    }        run_time_permissions(integer perm)    {        // Permissions are automatic when the object wearer is the owner        if (perm & PERMISSION_TRIGGER_ANIMATION) update();    }        listen(integer channel, string name, key id, string message)    {        // Dialog commands        if(channel == main_dialog_chat_channel)        {                     // Toggle owner messages                   if(message=="Messages")            {                if(verbose)                {                    verbose = FALSE;                    llOwnerSay("I will stop sending you status messages");                }                else                 {                    verbose = TRUE;                    llOwnerSay("I will send you status messages from now on");                                    }                return;            }                        // Stop dancing (works the same as turning off)            if(message=="Stop")            {                turn_off();                                   return;                   }                        // Give the user a copy of the instructions notecard            if(message=="Instructions")            {                llGiveInventory(avatar, "Animazoo dance HUD instructions v2.0");                return;            }                        // Give the user a landmark to the main store            if(message=="Landmark")            {                llGiveInventory(avatar, "Animazoo Brighton, Brightown (221, 69, 30)");                if(verbose) llOwnerSay("Visit Animazoo for more dances!");                return;             }                        // Show dialog giving option to change how often the dance changes            if(message=="Timing")            {                llDialog(avatar, spacer+spacer+"How often do you want the dance to change?", buttons_time, timing_dialog_chat_channel);                return;            }                    }                  if(channel == timing_dialog_chat_channel)        {            // Dialog messages from timing dialog. Sets the time between dance changes            if(message=="Never")     time_between_changes = 0;            if(message=="2 hours")    time_between_changes = 7200;            if(message=="1 hour")     time_between_changes = 3600;                     if(message=="3 minutes")  time_between_changes = 180;            if(message=="2 minutes")  time_between_changes = 120;            if(message=="1 minute")   time_between_changes = 60;            if(message=="30 seconds") time_between_changes = 30;            if(message=="20 seconds") time_between_changes = 20;            if(message=="10 seconds") time_between_changes = 10;            llSetTimerEvent((float) time_between_changes);            if(verbose)             {                if(time_between_changes>3599)                {                    integer time = time_between_changes/3600;                    if(time==1) llOwnerSay("I'll now change dance once an hour");                    else llOwnerSay("I'll now change dance every "+(string)time+" hours");                    return;                }                if(time_between_changes>59)                {                    integer time = time_between_changes/60;                    if(time==1) llOwnerSay("I'll now change dance once a minute");                    else llOwnerSay("I'll now change dance every "+(string)time+" minutes");                    return;                }                if(time_between_changes==0)                {                    llOwnerSay("I'll let you decide when to change dance from now on");                    return;                }                integer time = time_between_changes;                llOwnerSay("I'll now change dance every "+(string)time+" seconds");                return;                           }        }              }}

  

Link to comment
Share on other sites

snbad, I have a simple HUD I made long ago that I use for poses.  It has 3 buttons, on/off, forward and back.  Drop a copy of the animations you want in the HUD and wear it.  No timers, no menu, no frills.

 

If you want I'll send you a copy the next time I'm in world.  You can use it or open it up to look at what I did for the scripts if you want to write your own.

  • Like 1
Link to comment
Share on other sites

  • 2 years later...
On 31/7/2015 at 11:10 AM, Rhonda Huntress said:

 

Snbad, tengo un HUD simple hace mucho tiempo que uso para poses. Tiene 3 botones, encendido / apagado, adelante y atrás. Deja una copia de las animaciones que quieras en el HUD y úsala. Sin temporizadores, sin menú, sin lujos. Si quieres te enviaré una copia la próxima vez que esté en el mundo. Puede usarlo o abrirlo para ver lo que hice para los scripts si desea escribir los suyos.

 

Please you wanna help me?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2012 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...